]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Change an assert to an explicit exception.
authorBen Darnell <ben@bendarnell.com>
Tue, 20 May 2014 02:00:15 +0000 (22:00 -0400)
committerBen Darnell <ben@bendarnell.com>
Tue, 20 May 2014 02:00:15 +0000 (22:00 -0400)
Use normalized Http-Header-Case for X-Http-Reason header.

tornado/curl_httpclient.py
tornado/httputil.py

index 26401e3ec3e2ae09448ac7ec52f612aacaa54bf3..fc7d7f260810ec413f08c40e864b2059f077b23a 100644 (file)
@@ -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
index 17d6f1bb64d4592f921763b10ace7b4efaf15277..ee2f130eaa2e53e19e2d4aca14c58659e3f170d1 100644 (file)
@@ -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))