首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >apachebench (ab)和传输编码分块的问题

apachebench (ab)和传输编码分块的问题
EN

Stack Overflow用户
提问于 2010-12-03 20:39:17
回答 2查看 3.2K关注 0票数 0

我正在使用apachebench (ab)测试web服务器

此问题类似于this question

下面是一个请求的输出

代码语言:javascript
复制
 :: ab -c 1 -n 1 -v 5 -k http://localhost:8082/typealine
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)...INFO: POST header == 
---
GET /typealine HTTP/1.0
Connection: Keep-Alive
Host: localhost:8082
User-Agent: ApacheBench/2.3
Accept: */*


---
LOG: header received:
HTTP/1.1 200 OK
set-cookie: i=101203-012359.597-197269fc4;path=/;expires=Thu,31-Dec-2020 00:00:00 GMT;
content-type: text/html;charset=utf-8
Transfer-Encoding: chunked
Connection: Keep-Alive

205
<html><head><link href=/default.css rel=stylesheet><script src=/default.js></script></head><body onload=ui.onload()><form onsubmit=return(false)><center>
<div style="text-align:center;border:1px dotted blue;padding:7px"><span id=__st> ڀ </span><input value="" title="s" id=_s name=_s type=text onkeypress="return ui._cr(event,this,'_ a')" size=32 onchange="this._changed=true"> <a id=_ href="javascript:ui.ax('_ a')">ᐖ</a><script>document.getElementById('_s').focus();</script><br>
<br>
<span id=disp></span></div>
0


LOG: Response code = 200
..done


Server Software:        
Server Hostname:        localhost
Server Port:            8082

Document Path:          /typealine
Document Length:        0 bytes

Concurrency Level:      1
Time taken for tests:   0.001 seconds
Complete requests:      1
Failed requests:        0
Write errors:           0
Keep-Alive requests:    1
Total transferred:      721 bytes
HTML transferred:       0 bytes
Requests per second:    1312.34 [#/sec] (mean)
Time per request:       0.762 [ms] (mean)
Time per request:       0.762 [ms] (mean, across all concurrent requests)
Transfer rate:          924.02 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:     1    1   0.0      1       1
Waiting:        0    0   0.0      0       0
Total:          1    1   0.0      1       1

以下是失败的示例输出

代码语言:javascript
复制
 :: ab -c 1 -n 5 -v 5 -k http://localhost:8082/typealine
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)...INFO: POST header == 
---
GET /typealine HTTP/1.0
Connection: Keep-Alive
Host: localhost:8082
User-Agent: ApacheBench/2.3
Accept: */*


---
LOG: header received:
HTTP/1.1 200 OK
set-cookie: i=101203-012711.490-1fdea5f58;path=/;expires=Thu,31-Dec-2020 00:00:00 GMT;
content-type: text/html;charset=utf-8
Transfer-Encoding: chunked
Connection: Keep-Alive

205
<html><head><link href=/default.css rel=stylesheet><script src=/default.js></script></head><body onload=ui.onload()><form onsubmit=return(false)><center>
<div style="text-align:center;border:1px dotted blue;padding:7px"><span id=__st> ڀ </span><input value="" title="s" id=_s name=_s type=text onkeypress="return ui._cr(event,this,'_ a')" size=32 onchange="this._changed=true"> <a id=_ href="javascript:ui.ax('_ a')">ᐛ</a><script>document.getElementById('_s').focus();</script><br>
<br>
<span id=disp></span></div>
0


LOG: Response code = 200
LOG: header received:
HTTP/1.1 200 OK
set-cookie: i=101203-012711.490-10b9564e5;path=/;expires=Thu,31-Dec-2020 00:00:00 GMT;
content-type: text/html;charset=utf-8
Transfer-Encoding: chunked
Connection: Keep-Alive


LOG: Response code = 200
LOG: header received:
205
<html><head><link href=/default.css rel=stylesheet><script src=/default.js></script></head><body onload=ui.onload()><form onsubmit=return(false)><center>
<div style="text-align:center;border:1px dotted blue;padding:7px"><span id=__st> ڀ </span><input value="" title="s" id=_s name=_s type=text onkeypress="return ui._cr(event,this,'_ a')" size=32 onchange="this._changed=true"> <a id=_ href="javascript:ui.ax('_ a')">ᐖ</a><script>document.getElementById('_s').focus();</script><br>
<br>
<span id=disp></span></div>
0


WARNING: Response code not 2xx (500)
apr_poll: The timeout specified has expired (70007)
Total of 2 requests completed

我非常热衷于找出web服务器中的bug或确定ab是否有问题。

下面是模拟ab的telnet会话的输出

代码语言:javascript
复制
 :: telnet localhost 8082
Trying ::1...
Connected to localhost.localdomain.
Escape character is '^]'.
GET /typealine HTTP/1.0
Connection: Keep-Alive
Host: localhost:8082
User-Agent: ApacheBench/2.3
Accept: */*

HTTP/1.1 200 OK
set-cookie: i=101203-030537.389-1d3d8c1cb;path=/;expires=Thu,31-Dec-2020 00:00:00 GMT;
content-type: text/html;charset=utf-8
Transfer-Encoding: chunked
Connection: Keep-Alive

205
<html><head><link href=/default.css rel=stylesheet><script src=/default.js></script></head><body onload=ui.onload()><form onsubmit=return(false)><center>
<div style="text-align:center;border:1px dotted blue;padding:7px"><span id=__st> ڀ </span><input value="" title="s" id=_s name=_s type=text onkeypress="return ui._cr(event,this,'_ a')" size=32 onchange="this._changed=true"> <a id=_ href="javascript:ui.ax('_ a')">ᐖ</a><script>document.getElementById('_s').focus();</script><br>
<br>
<span id=disp></span></div>
0

GET /typealine HTTP/1.0
Connection: Keep-Alive
Host: localhost:8082
User-Agent: ApacheBench/2.3
Accept: */*

HTTP/1.1 200 OK
set-cookie: i=101203-030539.162-1d8b8c256;path=/;expires=Thu,31-Dec-2020 00:00:00 GMT;
content-type: text/html;charset=utf-8
Transfer-Encoding: chunked
Connection: Keep-Alive

205
<html><head><link href=/default.css rel=stylesheet><script src=/default.js></script></head><body onload=ui.onload()><form onsubmit=return(false)><center>
<div style="text-align:center;border:1px dotted blue;padding:7px"><span id=__st> ڀ </span><input value="" title="s" id=_s name=_s type=text onkeypress="return ui._cr(event,this,'_ a')" size=32 onchange="this._changed=true"> <a id=_ href="javascript:ui.ax('_ a')">ᐖ</a><script>document.getElementById('_s').focus();</script><br>
<br>
<span id=disp></span></div>
0

GET /typealine HTTP/1.0
Connection: Keep-Alive
Host: localhost:8082
User-Agent: ApacheBench/2.3
Accept: */*

HTTP/1.1 200 OK
set-cookie: i=101203-030541.086-18be1706b;path=/;expires=Thu,31-Dec-2020 00:00:00 GMT;
content-type: text/html;charset=utf-8
Transfer-Encoding: chunked
Connection: Keep-Alive

205
<html><head><link href=/default.css rel=stylesheet><script src=/default.js></script></head><body onload=ui.onload()><form onsubmit=return(false)><center>
<div style="text-align:center;border:1px dotted blue;padding:7px"><span id=__st> ڀ </span><input value="" title="s" id=_s name=_s type=text onkeypress="return ui._cr(event,this,'_ a')" size=32 onchange="this._changed=true"> <a id=_ href="javascript:ui.ax('_ a')">ᐛ</a><script>document.getElementById('_s').focus();</script><br>
<br>
<span id=disp></span></div>
0
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-12-03 20:56:52

从该输出看,在第二个响应的头部之后有一个额外的CRLF,而ab期望看到块长度。

票数 0
EN

Stack Overflow用户

发布于 2015-11-17 02:53:39

所以问题是,规范要求使用0 CRLF CRLF作为分块传输编码的结束标记。ab被破坏,因为它需要0和CRLF。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4345602

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档