Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom, non-standard, HTTP methods #90

Closed
nailor opened this issue May 18, 2010 · 1 comment
Closed

Support custom, non-standard, HTTP methods #90

nailor opened this issue May 18, 2010 · 1 comment

Comments

@nailor
Copy link

nailor commented May 18, 2010

This is more of a proposal than a bug report. Feel free to close this issue, if this is not desired behavior for Tornado.

Instead of limiting the AsyncHTTPClient's methods to standard PUT, POST, GET, HEAD and DELETE, Tornado could allow any custom HTTP method to be used. This has some benefits when working with certain applications, like CouchDB, where a non-standard method COPY is used to do an atomic copy of a document.

This behavior could easily be achieved with following patch

diff --git a/tornado/httpclient.py b/tornado/httpclient.py
index e45bfd6..fa152dc 100644
--- a/tornado/httpclient.py
+++ b/tornado/httpclient.py
@@ -390,16 +390,13 @@ def _curl_setup_request(curl, request, buffer, headers):
         "PUT": pycurl.UPLOAD,
         "HEAD": pycurl.NOBODY,
     }
-    custom_methods = set(["DELETE"])
     for o in curl_options.values():
         curl.setopt(o, False)
     if request.method in curl_options:
         curl.unsetopt(pycurl.CUSTOMREQUEST)
         curl.setopt(curl_options[request.method], True)
-    elif request.method in custom_methods:
-        curl.setopt(pycurl.CUSTOMREQUEST, request.method)
     else:
-        raise KeyError('unknown method ' + request.method)
+        curl.setopt(pycurl.CUSTOMREQUEST, request.method)
 
     # Handle curl's cryptic options for every individual HTTP method
     if request.method in ("POST", "PUT"):
@bdarnell
Copy link
Member

I don't want this to be the default (since, among other things, the method is currently case-sensitive and I don't know what would happen if you tried to pass in something lowercase), but I've added an option to HTTPRequest that will cause it to allow any method.

hellais referenced this issue in hellais/cyclone Feb 5, 2013
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants