Skip to content

Commit

Permalink
Merge pull request #19 from w3c/jgraham/read_whole_request
Browse files Browse the repository at this point in the history
Ensure that all of the request data is read from the socket when using a keepalive connection.
  • Loading branch information
jgraham committed Apr 22, 2014
2 parents 462685a + d21c83c commit ae75234
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion wptserve/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ def handle_one_request(self):
response.set_error(500, err)
logger.info("%i %s %s (%s) %i" % (response.status[0], request.method,
request.request_path, request.headers.get('Referer'), request.raw_input.length))

if not response.writer.content_written:
response.write()

Expand All @@ -224,7 +225,11 @@ def handle_one_request(self):
# can't set a Content-Length header. A notable example of this kind of
# problem is with the trickle pipe i.e. foo.js?pipe=trickle(d1)
if response.close_connection:
self.close_connection = 1
self.close_connection = True

if not self.close_connection:
# Ensure that the whole request has been read from the socket
request.raw_input.read()

except socket.timeout, e:
self.log_error("Request timed out: %r", e)
Expand Down

0 comments on commit ae75234

Please sign in to comment.