From: Tom Arnfeld Date: Tue, 22 Jul 2014 16:50:16 +0000 (+0100) Subject: Support for non-RFC compliant header prefixes X-Git-Tag: v4.1.0b1~128^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=016fa926d2f85f56a00703b0523d50e56b3f0a45;p=thirdparty%2Ftornado.git Support for non-RFC compliant header prefixes When using keep-alive connections, some HTTP implementations insert unexpected and extra CRLF tokens between each connection, which can result in the next request being prefixed with a CRLF. Some other client/server implementations are tollerant of this, and for example this bug doesn't show up when using the Go net/http library. --- diff --git a/tornado/http1connection.py b/tornado/http1connection.py index 72f729d78..0a6d87c10 100644 --- a/tornado/http1connection.py +++ b/tornado/http1connection.py @@ -471,7 +471,7 @@ class HTTP1Connection(httputil.HTTPConnection): self._finish_future.set_result(None) def _parse_headers(self, data): - data = native_str(data.decode('latin1')) + data = native_str(data.decode('latin1')).lstrip("\r\n") eol = data.find("\r\n") start_line = data[:eol] try: