Redirect (303) ignores accept header in favor of content-type if body defined

13 views
Skip to first unread message

Marc-Elian Bégin

unread,
Nov 7, 2011, 10:25:29 AM11/7/11
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

Joe Gregorio

unread,
Nov 7, 2011, 10:57:00 AM11/7/11
to httpli...@googlegroups.com
Sorry, as far as I can tell, what you are describing is the behavior
of the server and doesn't
have anything to do with httplib2.

-joe

> --
> You received this message because you are subscribed to the Google Groups "httplib2-dev" group.
> To post to this group, send email to httpli...@googlegroups.com.
> To unsubscribe from this group, send email to httplib2-dev...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/httplib2-dev?hl=en.
>
>

--
Joe Gregorio        http://bitworking.org

Marc-Elian Bégin

unread,
Dec 6, 2011, 8:44:16 AM12/6/11
to httplib2-dev
Yap... you're completely right... I was under the impression that the
header sent by httplib2 was wrong... but I was mistaking.

Forget about this.

Sorry,

Meb

> > For more options, visit this group athttp://groups.google.com/group/httplib2-dev?hl=en.

Reply all
Reply to author
Forward
0 new messages