From: Ben Darnell Date: Mon, 31 May 2010 06:04:10 +0000 (-0700) Subject: Optionally allow nonstandard http methods to be used in httpclient. X-Git-Tag: v1.0.0~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1e145039c40b0b50d8dac63c3ebaf53b8b5c8fa;p=thirdparty%2Ftornado.git 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 --- 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)