From d1e145039c40b0b50d8dac63c3ebaf53b8b5c8fa Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sun, 30 May 2010 23:04:10 -0700 Subject: [PATCH] Optionally allow nonstandard http methods to be used in httpclient. By default we check that the method is one of the standard ones (and is capitalized correctly), but this can be overridden to work with a server that has implemented nonstandard methods (e.g. CouchDB) http://github.com/facebook/tornado/issues/issue/90 --- tornado/httpclient.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tornado/httpclient.py b/tornado/httpclient.py index 6502d0d27..9e639391d 100644 --- a/tornado/httpclient.py +++ b/tornado/httpclient.py @@ -299,7 +299,8 @@ class HTTPRequest(object): if_modified_since=None, follow_redirects=True, max_redirects=5, user_agent=None, use_gzip=True, network_interface=None, streaming_callback=None, - header_callback=None, prepare_curl_callback=None): + header_callback=None, prepare_curl_callback=None, + allow_nonstandard_methods=False): if if_modified_since: timestamp = calendar.timegm(if_modified_since.utctimetuple()) headers["If-Modified-Since"] = email.utils.formatdate( @@ -322,6 +323,7 @@ class HTTPRequest(object): self.streaming_callback = streaming_callback self.header_callback = header_callback self.prepare_curl_callback = prepare_curl_callback + self.allow_nonstandard_methods = allow_nonstandard_methods class HTTPResponse(object): @@ -432,7 +434,7 @@ def _curl_setup_request(curl, request, buffer, headers): if request.method in curl_options: curl.unsetopt(pycurl.CUSTOMREQUEST) curl.setopt(curl_options[request.method], True) - elif request.method in custom_methods: + elif request.allow_nonstandard_methods or request.method in custom_methods: curl.setopt(pycurl.CUSTOMREQUEST, request.method) else: raise KeyError('unknown method ' + request.method) -- 2.47.2