测试中的http文件示例:https://github.com/netty/netty/tree/4.1/example/src/main/java/io/netty/example/http/file
我用netty-4.1.0.beta 8编译了上面的示例。
My test result:
$ ab -k -n 2 -c 1 -v 6 http://127.0.0.1:8080/test.sh
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 127.0.0.1 (be patient)...INFO: POST header ==
---
GET /test.sh HTTP/1.0
Connection: Keep-Alive
Host: 127.0.0.1:8080
User-Agent: ApacheBench/2.3
Accept: */*
---
LOG: header received:
HTTP/1.1 200 OK
content-length: 462
content-type: application/octet-stream
date: Fri, 26 Feb 2016 06:34:52 GMT
expires: Fri, 26 Feb 2016 06:35:52 GMT
cache-control: private, max-age=60
last-modified: Fri, 19 Feb 2016 02:35:40 GMT
connection: keep-alive
LOG: Response code = 200
LOG: header received:
**MY TEST.SH CONTENT**
WARNING: Response code not 2xx (500)
apr_poll: The timeout specified has expired (70007)
Total of 1 requests completed我的test.sh内容似乎被认为是第二个请求的头。
我的进一步测试:
$ ab -k -n 1 -c 1 -v 6 http://127.0.0.1:8080/test.sh
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 127.0.0.1 (be patient)...INFO: POST header ==
---
GET /test.sh HTTP/1.0
Connection: Keep-Alive
Host: 127.0.0.1:8080
User-Agent: ApacheBench/2.3
Accept: */*
---
LOG: header received:
HTTP/1.1 200 OK
content-length: 462
content-type: application/octet-stream
date: Fri, 26 Feb 2016 06:39:02 GMT
expires: Fri, 26 Feb 2016 06:40:02 GMT
cache-control: private, max-age=60
last-modified: Fri, 19 Feb 2016 02:35:40 GMT
connection: keep-alive
LOG: Response code = 200
..done
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8080
Document Path: /test.sh
Document Length: 0 bytes
Concurrency Level: 1
Time taken for tests: 0.005 seconds
Complete requests: 1
Failed requests: 0
Write errors: 0
Keep-Alive requests: 1
Total transferred: 263 bytes
HTML transferred: 0 bytes
Requests per second: 209.25 [#/sec] (mean)
Time per request: 4.779 [ms] (mean)
Time per request: 4.779 [ms] (mean, across all concurrent requests)
Transfer rate: 53.74 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 5 5 0.0 5 5
Waiting: 5 5 0.0 5 5
Total: 5 5 0.0 5 5您可以看到文档长度为0字节。
我在www.google.com上运行了类似的命令,它运行得很好。你能帮个忙吗?提前谢谢。
发布于 2016-02-29 08:01:12
这是ApacheBench中的一个bug。
ApacheBench没有完全遵循http规范,并且假定头具有一定的大写。由于netty应用程序返回的标头没有ApacheBench所期望的字符大小写,所以它假定内容长度的默认值为0字节。
HTTP标头字段包括通用标头(4.5节)、请求标头(5.3节)、响应-标头(6.2节)和实体-标头(7.1节)字段,与RFC 822 9第3.1节中给出的格式相同。每个标头字段由一个名称和一个冒号(":")和字段值组成。字段名是不区分大小写的。字段值可能前面有任意数量的LWS,但首选单个SP。头字段可以扩展到多行,方法是在每个额外行之前至少有一个SP或HT。在生成HTTP构造时,应用程序应该遵循“公共形式”,其中一个是已知的或指示的,因为可能有一些实现不能接受公共表单之外的任何内容。
因为ApacheBench的“保持活动”开关迫使它假设服务器支持“保持活动”,所以它不会检测到“丢失”的“保持活动”数据包头。
但是,如果需要在ApacheBench中解决一些问题,因为是应用程序中的一个错误导致它错过了适当的内容长度,那么就会出现这个问题。
https://stackoverflow.com/questions/35690830
复制相似问题