urllib2 - My POST Request just isn't working right

David Wahler dwahler at gmail.com
Wed Feb 1 11:41:06 EST 2006


Gregory Piñero wrote:
> Ok, I tried the changes you guys suggested but same error still:
> 1. Corrected spelling of referrer.
> 2. Don't specify host.
>
> Here is what they say my request should look like:
> -------------------------------------------------------------------------
> POST /GatewayDC HTTP/1.0
> Referer: YourCompanyNameGoesHere
> Host: SSLserver.fedex.com
> Accept: image/gif, image/jpeg, image/pjpeg, text/plain, text/html, */*
> Content-Type: image/gif Content-length: %d
>
> Your FedEx Transaction
> -------------------------------------------------------------------------
> Note that Host here is ficticious.  My host should be correct.  And
> they have referrer mispelled here so who knows which to use!
>

"Referer" is the correct header name. The HTTP specification spells it
incorrectly, so "Referrer" is the proper English spelling but invalid
in the context of HTTP. This is for historical reasons, and is not
likely to change.

> Here are some suspicions I have:
>
> 1 . One thing that is weird is that the data part just says "Your
> FedEx Transaction".  I know I put the XML here, but I also notice that
> urllib2 is putting this as:
>
> request=<xml ....
>
> Can I have my xml placed here without that something= part?  That
> don't specify what parameter name I should use.

Are you sure it's supposed to be URL-encoded? Try just sending the XML
data directly as part of the request.

-- David




More information about the Python-list mailing list