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.
This commit is contained in:
Ben Darnell 2010-08-09 14:33:32 -07:00
parent 00ce7d4d99
commit cd888f2f00
1 changed files with 3 additions and 1 deletions

View File

@ -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)