Add a way to force FRESH_CONNECT to pycurl.
Sometimes if the hosts IP address changes, pycurl
gets hosed up. Forcing a fresh connection might
help alleviate the backup.
Change-Id: I15363c3911f971699b639d09baf9be639542d947
diff --git a/tornado/curl_httpclient.py b/tornado/curl_httpclient.py
index 753ccd1..852eec9 100644
--- a/tornado/curl_httpclient.py
+++ b/tornado/curl_httpclient.py
@@ -354,6 +354,11 @@
# (but see version check in _process_queue above)
curl.setopt(pycurl.IPRESOLVE, pycurl.IPRESOLVE_V4)
+ if request.fresh_connect:
+ curl.setopt(pycurl.FRESH_CONNECT, 1)
+ else:
+ curl.setopt(pycurl.FRESH_CONNECT, 0)
+
# Set the request method through curl's irritating interface which makes
# up names for almost every single method
curl_options = {
diff --git a/tornado/httpclient.py b/tornado/httpclient.py
index a4a3728..d73fe4c 100644
--- a/tornado/httpclient.py
+++ b/tornado/httpclient.py
@@ -234,7 +234,8 @@
proxy_password='', allow_nonstandard_methods=False,
validate_cert=True, ca_certs=None,
allow_ipv6=None,
- client_key=None, client_cert=None):
+ client_key=None, client_cert=None,
+ fresh_connect=False):
"""Creates an `HTTPRequest`.
All parameters except `url` are optional.
@@ -285,6 +286,8 @@
`simple_httpclient` and true in `curl_httpclient`
:arg string client_key: Filename for client SSL key, if any
:arg string client_cert: Filename for client SSL certificate, if any
+ :arg fresh_connect: For curl_httpclient, set the FRESH_CONNECT flag for
+ this request.
"""
if headers is None:
headers = httputil.HTTPHeaders()
@@ -318,6 +321,7 @@
self.allow_ipv6 = allow_ipv6
self.client_key = client_key
self.client_cert = client_cert
+ self.fresh_connect = fresh_connect
self.start_time = monotime()