From: Ben Darnell Date: Tue, 20 May 2014 02:00:15 +0000 (-0400) Subject: Change an assert to an explicit exception. X-Git-Tag: v4.0.0b1~55 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d56c5c22d7869f895b4bc18308c6560604eab00;p=thirdparty%2Ftornado.git Change an assert to an explicit exception. Use normalized Http-Header-Case for X-Http-Reason header. --- diff --git a/tornado/curl_httpclient.py b/tornado/curl_httpclient.py index 26401e3ec..fc7d7f260 100644 --- a/tornado/curl_httpclient.py +++ b/tornado/curl_httpclient.py @@ -268,7 +268,7 @@ class CurlAsyncHTTPClient(AsyncHTTPClient): info["callback"](HTTPResponse( request=info["request"], code=code, headers=info["headers"], buffer=buffer, effective_url=effective_url, error=error, - reason=info['headers'].get("x-http-reason", None), + reason=info['headers'].get("X-Http-Reason", None), request_time=time.time() - info["curl_start_time"], time_info=time_info)) except Exception: @@ -473,8 +473,8 @@ def _curl_header_callback(headers, header_line): headers.clear() try: (__, __, reason) = httputil.parse_response_start_line(header_line) - header_line = "X-HTTP-Reason: %s" % reason - except AssertionError: + header_line = "X-Http-Reason: %s" % reason + except httputil.HTTPInputException: return if not header_line: return diff --git a/tornado/httputil.py b/tornado/httputil.py index 17d6f1bb6..ee2f130ea 100644 --- a/tornado/httputil.py +++ b/tornado/httputil.py @@ -794,7 +794,8 @@ def parse_response_start_line(line): """ line = native_str(line) match = re.match("(HTTP/1.[01]) ([0-9]+) ([^\r]*)", line) - assert match + if not match: + raise HTTPInputException("Error parsing response start line") return ResponseStartLine(match.group(1), int(match.group(2)), match.group(3))