Skip to content

Commit

Permalink
Disable Expect header in curl_httpclient.py without clearing all head…
Browse files Browse the repository at this point in the history
…ers.

Fixes previous fix (18f942b).
  • Loading branch information
neilrahilly committed Mar 28, 2011
1 parent 18f942b commit c5b9847
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tornado/curl_httpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,6 @@ def _curl_create(max_simultaneous_connections=None):

def _curl_setup_request(curl, request, buffer, headers):
curl.setopt(pycurl.URL, request.url)
# Request headers may be either a regular dict or HTTPHeaders object
if isinstance(request.headers, httputil.HTTPHeaders):
curl.setopt(pycurl.HTTPHEADER,
[utf8("%s: %s" % i) for i in request.headers.get_all()])
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,
Expand All @@ -297,7 +290,15 @@ def _curl_setup_request(curl, request, buffer, headers):
# 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: ")])
request.headers["Expect"] = ""

# Request headers may be either a regular dict or HTTPHeaders object
if isinstance(request.headers, httputil.HTTPHeaders):
curl.setopt(pycurl.HTTPHEADER,
[utf8("%s: %s" % i) for i in request.headers.get_all()])
else:
curl.setopt(pycurl.HTTPHEADER,
[utf8("%s: %s" % i) for i in request.headers.iteritems()])

if request.header_callback:
curl.setopt(pycurl.HEADERFUNCTION, request.header_callback)
Expand Down

0 comments on commit c5b9847

Please sign in to comment.