From: Ben Darnell Date: Mon, 9 Aug 2010 21:33:32 +0000 (-0700) Subject: Be less picky about line endings in headers in httpclient. X-Git-Tag: v1.1.0~42 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cd888f2f00228d8154c3ec043a1488dad5e07803;p=thirdparty%2Ftornado.git Be less picky about line endings in headers in httpclient. HTTP requires that lines end with \r\n, but some buggy servers (including news.ycombinator.com) just use \n. Libcurl tolerates this and sends the line as-is to the header callback, so we need to be prepared to handle either form. --- diff --git a/tornado/httpclient.py b/tornado/httpclient.py index 8894a64a5..6cba70dae 100644 --- a/tornado/httpclient.py +++ b/tornado/httpclient.py @@ -579,10 +579,12 @@ def _curl_setup_request(curl, request, buffer, headers): def _curl_header_callback(headers, header_line): + # header_line as returned by curl includes the end-of-line characters. + header_line = header_line.strip() if header_line.startswith("HTTP/"): headers.clear() return - if header_line == "\r\n": + if not header_line: return headers.parse_line(header_line)