HTTP client doesn't support DELETE method?

250 views
Skip to first unread message

David King

unread,
Dec 9, 2009, 4:26:09 PM12/9/09
to python-...@googlegroups.com
When I try to use the DELETE method with the HTTP client, I get:

Traceback (most recent call last):
File "/Users/dking/src/reddit/rdb/rdbclient.py", line 154, in delete
resp = self.http.fetch(req)
File "/usr/local/lib/python2.6/site-packages/tornado/httpclient.py", line 63, in fetch
File "/usr/local/lib/python2.6/site-packages/tornado/httpclient.py", line 372, in _curl_setup_request
KeyError: 'DELETE'

It looks like this is happening here (http://github.com/facebook/tornado/blob/master/tornado/httpclient.py#L364):

curl_options = {
"GET": pycurl.HTTPGET,
"POST": pycurl.POST,
"PUT": pycurl.UPLOAD,
"HEAD": pycurl.NOBODY,
}

for o in curl_options.values():
curl.setopt(o, False)
curl.setopt(curl_options[request.method], True)

Is this a quick-fix, or does pycurl just not support the method?

Gabriel Farrell

unread,
Dec 9, 2009, 5:45:51 PM12/9/09
to python-...@googlegroups.com
The DELETE method is supported by pycurl in the same way it supports
any other libcurl option. The documentation for DELETE via curl is at
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCUSTOMREQUEST,
where they note:

This is useful for doing DELETE or other more or less obscure HTTP requests.

If you would like to add the functionality to Tornado, you could use
something similar to
http://hg.basho.com/riak/src/tip/client_lib/jiak.py#cl-110 in that
section of httpclient.py you pointed to.

Bret Taylor

unread,
Dec 9, 2009, 5:55:04 PM12/9/09
to python-...@googlegroups.com
We should fix this. Mind filing a bug in github, David?

David King

unread,
Dec 9, 2009, 6:04:29 PM12/9/09
to python-...@googlegroups.com
> We should fix this. Mind filing a bug in github, David?

Done. http://github.com/facebook/tornado/issues/#issue/40

Reply all
Reply to author
Forward
0 new messages