]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Support for non-RFC compliant header prefixes 1124/head
authorTom Arnfeld <tarnfeld@me.com>
Tue, 22 Jul 2014 16:50:16 +0000 (17:50 +0100)
committerTom Arnfeld <tarnfeld@me.com>
Wed, 23 Jul 2014 08:28:42 +0000 (09:28 +0100)
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.

tornado/http1connection.py

index 72f729d784c28aa9d5ea2dd3de81fd26b84ef849..0a6d87c103efb1b1209462e18e36a6c76c43693e 100644 (file)
@@ -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: