{"action":"created","issue":{"url":"https://api.github.com/repos/KeepSafe/aiohttp/issues/934","repository_url":"https://api.github.com/repos/KeepSafe/aiohttp","labels_url":"https://api.github.com/repos/KeepSafe/aiohttp/issues/934/labels{/name}","comments_url":"https://api.github.com/repos/KeepSafe/aiohttp/issues/934/comments","events_url":"https://api.github.com/repos/KeepSafe/aiohttp/issues/934/events","html_url":"https://github.com/KeepSafe/aiohttp/issues/934","id":161061300,"number":934,"title":"Uppercase header is incompatible with ab (Apache Bench)","user":{"login":"iceboy-sjtu","id":1206456,"avatar_url":"https://avatars.githubusercontent.com/u/1206456?v=3","gravatar_id":"","url":"https://api.github.com/users/iceboy-sjtu","html_url":"https://github.com/iceboy-sjtu","followers_url":"https://api.github.com/users/iceboy-sjtu/followers","following_url":"https://api.github.com/users/iceboy-sjtu/following{/other_user}","gists_url":"https://api.github.com/users/iceboy-sjtu/gists{/gist_id}","starred_url":"https://api.github.com/users/iceboy-sjtu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iceboy-sjtu/subscriptions","organizations_url":"https://api.github.com/users/iceboy-sjtu/orgs","repos_url":"https://api.github.com/users/iceboy-sjtu/repos","events_url":"https://api.github.com/users/iceboy-sjtu/events{/privacy}","received_events_url":"https://api.github.com/users/iceboy-sjtu/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-06-19T07:44:51Z","updated_at":"2016-07-31T18:38:52Z","closed_at":"2016-07-31T18:38:52Z","body":"## Long story short\r\n\r\n`ab` hangs when keep-alive enabled and the response is long.\r\n\r\n## Expected behaviour\r\n\r\n```python\r\nfrom aiohttp import web\r\n\r\nasync def handle(request):\r\n    return web.Response(body=b'x' * 16384)\r\n\r\napp = web.Application()\r\napp.router.add_route('GET', '/', handle)\r\nweb.run_app(app)\r\n```\r\n\r\nExpect `ab -k -n 2 http://127.0.0.1:8080/` to work.\r\n\r\n## Actual behaviour\r\n\r\n`ab` hangs after sending the second request.\r\n\r\n## Cause and suggestion\r\n\r\n`ab` fails to parse `CONTENT-LENGTH`. From the source code of `ab` we can see that there is some hand-craft HTTP parser (`httpd/support/ab.c:read_connection`):\r\n\r\n```c\r\nif (keepalive &&\r\n(strstr(c->cbuff, \"Keep-Alive\")\r\n || strstr(c->cbuff, \"keep-alive\"))) {  /* for benefit of MSIIS */\r\n    char *cl;\r\n    cl = strstr(c->cbuff, \"Content-Length:\");\r\n    /* handle NCSA, which sends Content-length: */\r\n    if (!cl)\r\n        cl = strstr(c->cbuff, \"Content-length:\");\r\n    if (cl) {\r\n        c->keepalive = 1;\r\n        /* response to HEAD doesn't have entity body */\r\n        c->length = method != HEAD ? atoi(cl + 16) : 0;\r\n    }\r\n    /* The response may not have a Content-Length header */\r\n    if (!cl) {\r\n        c->keepalive = 1;\r\n        c->length = 0;\r\n    }\r\n}\r\n```\r\n\r\nAlthough it's `ab` that violates the HTTP standard, considering that `ab` is a common tool for HTTP benchmarking, the behavior that `ab` works on other HTTP library and only hangs on `aiohttp` will frustrate users. Making HTTP headers camel case also have other benefits discussed in #223, #813.\r\n\r\n## Steps to reproduce\r\n\r\nInstall `aiohttp` and `ab`, and use the above example program and command line.\r\n\r\n## Your environment\r\n\r\nLinux iceboy-m7h 4.6.2-1-ARCH #1 SMP PREEMPT Wed Jun 8 08:40:59 CEST 2016 x86_64 GNU/Linux\r\nPython 3.5.1\r\naiohttp==0.21.6\r\nThis is ApacheBench, Version 2.3 <$Revision: 1706008 $>"},"comment":{"url":"https://api.github.com/repos/KeepSafe/aiohttp/issues/comments/236448752","html_url":"https://github.com/KeepSafe/aiohttp/issues/934#issuecomment-236448752","issue_url":"https://api.github.com/repos/KeepSafe/aiohttp/issues/934","id":236448752,"user":{"login":"asvetlov","id":356399,"avatar_url":"https://avatars.githubusercontent.com/u/356399?v=3","gravatar_id":"","url":"https://api.github.com/users/asvetlov","html_url":"https://github.com/asvetlov","followers_url":"https://api.github.com/users/asvetlov/followers","following_url":"https://api.github.com/users/asvetlov/following{/other_user}","gists_url":"https://api.github.com/users/asvetlov/gists{/gist_id}","starred_url":"https://api.github.com/users/asvetlov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asvetlov/subscriptions","organizations_url":"https://api.github.com/users/asvetlov/orgs","repos_url":"https://api.github.com/users/asvetlov/repos","events_url":"https://api.github.com/users/asvetlov/events{/privacy}","received_events_url":"https://api.github.com/users/asvetlov/received_events","type":"User","site_admin":false},"created_at":"2016-07-31T18:38:51Z","updated_at":"2016-07-31T18:38:51Z","body":"Fixed by #1015"}}
{"actor":{"display_login":"asvetlov"}}