When a wsgi application gives a unicode object to the server, which the spec says causes undefined behavior, write a 500 error to the browser instead of just hanging forever.
This commit is contained in:
@@ -181,7 +181,10 @@ class HttpProtocol(BaseHTTPServer.BaseHTTPRequestHandler):
|
|||||||
towrite.append(data)
|
towrite.append(data)
|
||||||
joined = ''.join(towrite)
|
joined = ''.join(towrite)
|
||||||
length[0] = length[0] + len(joined)
|
length[0] = length[0] + len(joined)
|
||||||
_write(joined)
|
try:
|
||||||
|
_write(joined)
|
||||||
|
except UnicodeEncodeError:
|
||||||
|
_write("HTTP/1.0 500 Internal Server Error\r\nConnection: close\r\nContent-type: text/plain\r\nContent-length: 98\r\n\r\nInternal Server Error: wsgi application passed a unicode object to the server instead of a string.")
|
||||||
|
|
||||||
def start_response(status, response_headers, exc_info=None):
|
def start_response(status, response_headers, exc_info=None):
|
||||||
status_code[0] = status.split()[0]
|
status_code[0] = status.split()[0]
|
||||||
|
Reference in New Issue
Block a user