]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Move curl Expect: header hack from httpclient.py to curl_httpclient.py.
authorBen Darnell <ben@bendarnell.com>
Tue, 15 Mar 2011 06:06:05 +0000 (23:06 -0700)
committerBen Darnell <ben@bendarnell.com>
Tue, 15 Mar 2011 06:06:05 +0000 (23:06 -0700)
Fixes: #233.
tornado/curl_httpclient.py
tornado/httpclient.py

index 728c0b380ea92d21a1294d731cd9646510c2a308..326e5499aa894cd97fda57594da5a660df386dbe 100644 (file)
@@ -287,6 +287,18 @@ def _curl_setup_request(curl, request, buffer, headers):
     else:
         curl.setopt(pycurl.HTTPHEADER,
                     [utf8("%s: %s" % i) for i in request.headers.iteritems()])
+
+    # libcurl's magic "Expect: 100-continue" behavior causes delays
+    # with servers that don't support it (which include, among others,
+    # Google's OpenID endpoint).  Additionally, this behavior has
+    # a bug in conjunction with the curl_multi_socket_action API
+    # (https://sourceforge.net/tracker/?func=detail&atid=100976&aid=3039744&group_id=976),
+    # which increases the delays.  It's more trouble than it's worth,
+    # so just turn off the feature (yes, setting Expect: to an empty
+    # value is the official way to disable this)
+    if "Expect" not in request.headers:
+        curl.setopt(pycurl.HTTPHEADER, utf8("Expect: "))
+
     if request.header_callback:
         curl.setopt(pycurl.HEADERFUNCTION, request.header_callback)
     else:
index 63107dd8f2c7de131307864ec956c84b4498ef7c..d7d500d65d8941f537fd7b1cd8836baa727375ac 100644 (file)
@@ -169,16 +169,6 @@ class HTTPRequest(object):
         self.proxy_port = proxy_port
         self.proxy_username = proxy_username
         self.proxy_password = proxy_password
-        # libcurl's magic "Expect: 100-continue" behavior causes delays
-        # with servers that don't support it (which include, among others,
-        # Google's OpenID endpoint).  Additionally, this behavior has
-        # a bug in conjunction with the curl_multi_socket_action API
-        # (https://sourceforge.net/tracker/?func=detail&atid=100976&aid=3039744&group_id=976),
-        # which increases the delays.  It's more trouble than it's worth,
-        # so just turn off the feature (yes, setting Expect: to an empty
-        # value is the official way to disable this)
-        if "Expect" not in headers:
-            headers["Expect"] = ""
         self.url = utf8(url)
         self.method = method
         self.headers = headers