Skip to content

Commit

Permalink
WSGIContainer now uses HTTPConnection to write its response.
Browse files Browse the repository at this point in the history
  • Loading branch information
bdarnell committed Mar 14, 2015
1 parent 42b9e6f commit 859df38
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tornado/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ def start_response(status, response_headers, exc_info=None):
if not data:
raise Exception("WSGI app did not call start_response")

status_code = int(data["status"].split()[0])
status_code, reason = data["status"].split(' ', 1)
status_code = int(status_code)
headers = data["headers"]
header_set = set(k.lower() for (k, v) in headers)
body = escape.utf8(body)
Expand All @@ -296,13 +297,12 @@ def start_response(status, response_headers, exc_info=None):
if "server" not in header_set:
headers.append(("Server", "TornadoServer/%s" % tornado.version))

parts = [escape.utf8("HTTP/1.1 " + data["status"] + "\r\n")]
start_line = httputil.ResponseStartLine("HTTP/1.1", status_code, reason)
header_obj = httputil.HTTPHeaders()
for key, value in headers:
parts.append(escape.utf8(key) + b": " + escape.utf8(value) + b"\r\n")
parts.append(b"\r\n")
parts.append(body)
request.write(b"".join(parts))
request.finish()
header_obj.add(key, value)
request.connection.write_headers(start_line, header_obj, chunk=body)
request.connection.finish()
self._log(status_code, request)

@staticmethod
Expand Down

0 comments on commit 859df38

Please sign in to comment.