From 016fa926d2f85f56a00703b0523d50e56b3f0a45 Mon Sep 17 00:00:00 2001 From: Tom Arnfeld Date: Tue, 22 Jul 2014 17:50:16 +0100 Subject: [PATCH] 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. --- tornado/http1connection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: -- 2.47.2