From: Ben Darnell Date: Fri, 29 Jan 2010 00:44:20 +0000 (-0800) Subject: Add a hook to allow applications to modify the curl objects directly. X-Git-Tag: v1.0.0~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e30e28bcfb9a8880bc1889c425e36f1c1476e930;p=thirdparty%2Ftornado.git Add a hook to allow applications to modify the curl objects directly. --- diff --git a/tornado/httpclient.py b/tornado/httpclient.py index ae4abe338..dc243ca0a 100644 --- a/tornado/httpclient.py +++ b/tornado/httpclient.py @@ -260,7 +260,8 @@ class HTTPRequest(object): connect_timeout=20.0, request_timeout=20.0, if_modified_since=None, follow_redirects=True, max_redirects=5, user_agent=None, use_gzip=True, - network_interface=None, streaming_callback=None): + network_interface=None, streaming_callback=None, + prepare_curl_callback=None): if if_modified_since: timestamp = calendar.timegm(if_modified_since.utctimetuple()) headers["If-Modified-Since"] = email.utils.formatdate( @@ -281,6 +282,7 @@ class HTTPRequest(object): self.use_gzip = use_gzip self.network_interface = network_interface self.streaming_callback = streaming_callback + self.prepare_curl_callback = prepare_curl_callback class HTTPResponse(object): @@ -404,6 +406,8 @@ def _curl_setup_request(curl, request, buffer, headers): else: curl.unsetopt(pycurl.USERPWD) logging.info("%s %s", request.method, request.url) + if request.prepare_curl_callback is not None: + request.prepare_curl_callback(curl) def _curl_header_callback(headers, header_line):