Skip to content

Commit

Permalink
Use a lambda instead of functools.partial for pycurl.HEADERFUNCTION.
Browse files Browse the repository at this point in the history
Older versions of pycurl (including 7.16.2.1, which is the recommended
version for Mac OS X 10.5) only work with real functions, not objects
with a __call__ method like functools.partial.

Remove exception-swallowing - curl versions that predate HEADERFUNCTION
are no longer supported.
  • Loading branch information
Ben Darnell committed May 17, 2010
1 parent e8dec4d commit 0c36366
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions tornado/httpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,15 +358,11 @@ def _curl_setup_request(curl, request, buffer, headers):
curl.setopt(pycurl.URL, request.url)
curl.setopt(pycurl.HTTPHEADER,
["%s: %s" % i for i in request.headers.iteritems()])
try:
if request.header_callback:
curl.setopt(pycurl.HEADERFUNCTION, request.header_callback)
else:
curl.setopt(pycurl.HEADERFUNCTION,
functools.partial(_curl_header_callback, headers))
except:
# Old version of curl; response will not include headers
pass
if request.header_callback:
curl.setopt(pycurl.HEADERFUNCTION, request.header_callback)
else:
curl.setopt(pycurl.HEADERFUNCTION,
lambda line: _curl_header_callback(headers, line))
if request.streaming_callback:
curl.setopt(pycurl.WRITEFUNCTION, request.streaming_callback)
else:
Expand Down

0 comments on commit 0c36366

Please sign in to comment.