extend http_connection unit test to cover no keep-alive

This commit is contained in:
Arvid Norberg 2015-01-05 16:17:23 +00:00
parent a462f58372
commit c2e5df57b5
2 changed files with 11 additions and 0 deletions

View File

@ -225,10 +225,17 @@ int test_main()
#endif
// test chunked encoding
fprintf(stderr, "\ntest chunked encoding\n\n");
port = start_web_server(false, true);
ps.type = settings_pack::none;
run_suite("http", ps, port);
// test no keep-alive
fprintf(stderr, "\ntest no keep-alive\n\n");
port = start_web_server(false, false, false);
ps.type = settings_pack::none;
run_suite("http", ps, port);
stop_web_server();
std::remove("test_file");
return 0;

View File

@ -124,6 +124,10 @@ class http_handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
s.send_header('Content-Encoding', 'gzip')
if not keepalive:
s.send_header("Connection", "close")
try:
s.request.shutdown(SHUT_RD);
except Exception, e:
print 'Failed to shutdown read-channel of socket: ', e
s.end_headers()