Skip to content

Commit

Permalink
Move curl Expect: header hack from httpclient.py to curl_httpclient.py.
Browse files Browse the repository at this point in the history
Fixes: #233.
  • Loading branch information
bdarnell committed Mar 15, 2011
1 parent 6f0a8a7 commit 425f069
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
12 changes: 12 additions & 0 deletions tornado/curl_httpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 0 additions & 10 deletions tornado/httpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,6 @@ def __init__(self, url, method="GET", headers=None, body=None,
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
Expand Down

0 comments on commit 425f069

Please sign in to comment.