Skip to content

Commit

Permalink
Optionally allow nonstandard http methods to be used in httpclient.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Ben Darnell committed May 31, 2010
1 parent d5a3d8a commit d1e1450
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tornado/httpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ def __init__(self, url, method="GET", headers={}, body=None,
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(
Expand All @@ -322,6 +323,7 @@ def __init__(self, url, method="GET", headers={}, body=None,
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):
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d1e1450

Please sign in to comment.