Marc-Elian Bégin
unread,Nov 7, 2011, 10:25:29 AM11/7/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to httplib2-dev
Hi,
When using the REST POST/REDIRECT/GET pattern, with httplib2, the GET
part of the pattern fails to specify the right request media-type, if
a body is provided in the POST request.
For example:-,
response = h.request('<some resource url>', 'POST', '',
headers={'Accept':'application/json', 'content-type':'application/x-
www-form-urlencoded'})
in this case, since the body is an empty string (same for None), the
response is in the right media-type, 'application/json'.
However, if I request:
_,response = h.request('<some resource url>', 'POST', 'foo=bar',
headers={'Accept':'application/json', 'content-type':'application/x-
www-form-urlencoded'})
the response contains a body in html format, which is consistent with
the servers approximation of 'application/x-www-form-urlencoded' as
its supported media-types.
I think that when specified, the 'accept' header should trump any
'content-type' specified in the POST request.
Any light on this would be appreciated.
Thanks,
Meb