]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Use parse_response_start_line instead of re
authordano <oreilldf@gmail.com>
Wed, 14 May 2014 14:48:38 +0000 (10:48 -0400)
committerdano <oreilldf@gmail.com>
Wed, 14 May 2014 14:48:38 +0000 (10:48 -0400)
tornado/curl_httpclient.py

index 3fc171593bb28f831acc787d4255d083403a429f..c489f00fb4c3747ffc1df21da1b422a7eb378fc4 100644 (file)
@@ -23,7 +23,6 @@ import logging
 import pycurl
 import threading
 import time
-import re
 
 from tornado import httputil
 from tornado import ioloop
@@ -472,9 +471,11 @@ def _curl_header_callback(headers, header_line):
     header_line = header_line.strip()
     if header_line.startswith("HTTP/"):
         headers.clear()
-        m = re.search("HTTP\/\S*\s*\d+\s*(.*?)\s*$", header_line)
-        if m:
-            header_line = "Reason: %s" % m.group(1)
+        try:
+            (__, __, reason) = httputil.parse_response_start_line(header_line)
+            header_line = "Reason: %s" % reason
+        except AssertionError:
+            pass
     if not header_line:
         return
     headers.parse_line(header_line)