[Twisted-web] request.args empty when rendering PUT?

Jarek Zgoda jarek.zgoda at sensisoft.com
Wed Mar 28 06:24:00 CST 2007

L. Daniel Burr napisał(a):

>> I just discovered, that when using twisted.web and resource framework,
>> request.args are empty when I render the PUT method. Specifically, if I
>> issue http.request('PUT', path, params, headers) (http is
>> httplib.HTTPConnection object) and the params is urlencoded dictionary,
>> in the resource's render_PUT method I get request.args equal to {}. Is
>> this intended, or should I do something to enable passing data to PUT
>> method?
> I've never had a problem using PUT with twisted,web; I've had one such
> application running for over 2 years without a problem.
> Could you please provide some more details, perhaps a snippet of how
> the client-code is calling your twisted.web server?  It is most likely
> something simple that is preventing your code from working as you desire.

The code that produces failure:

path = '/indexer'
headers = {
    'Content-Type': 'application/x-www-form-urlencoded',
    'accept': 'text/plain',
docs = [{'field1': 'value1', 'field2': 'value2'}]
params = urllib.urlencode({'items': pickle.dumps(docs)})
http = httplib.HTTPConnection('localhost', 8080)
    http.request('PUT', path, params, headers)
    response = http.getresponse()
    print response.reason

The dictionary I get as request.args is empty.

> Also, have you tried sending the PUT "by hand", i.e., using telnet to
> send the PUT line-by-line, or using curl, or some other client besides
> httplib?

Will try this.

Jarek Zgoda

"We read Knuth so you don't have to."

More information about the Twisted-web mailing list