jonashaag/bjoern — Issue #51: Keepalive not working? 
Author: jameslittle
Created: 2012-01-10 16:36:26+00:00
State: open

Testing with apachebench and curl; verbose output from curl, which you can see tries to reuse the connection:
```
curl -v http://192.168.1.190:8081 http://192.168.1.190:8081
* About to connect() to 192.168.1.190 port 8081 (#0)
* Trying 192.168.1.190... connected
> GET / HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-unknown-linux-gnu) libcurl/7.22.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18
> Host: 192.168.1.190:8081
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-type: text/plain
< Content-Length: 5
<
* Connection #0 to host 192.168.1.190 left intact
* Connection #0 seems to be dead!
* Closing connection #0
* About to connect() to 192.168.1.190 port 8081 (#0)
* Trying 192.168.1.190... connected
> GET / HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-unknown-linux-gnu) libcurl/7.22.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18
> Host: 192.168.1.190:8081
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-type: text/plain
< Content-Length: 5
<
* Connection #0 to host 192.168.1.190 left intact
* Closing connection #0
Pong!Pong
```

Note the 'connection seems to be dead' line, and that the content of *two* responses seems to come all at once at the end ("Pong!Pong!"), rather than displayed inline with the request as Curl would normally do.
apachebench with -k flag will just hang after making a connection (presumably after the first request is served).

Here's my test app:
```
#!/usr/bin/python

import bjoern

def application(environ, start_response):
status = '200 OK'
output = 'Pong!'

response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]

bjoern.run(application, '192.168.1.190', 8081)
```

Testing with the latest code base.