urllib2.Request:: http Request sending successfully, but Response contains in valid data.

Tino Wildenhain tino at wildenhain.de
Wed Feb 11 10:47:56 EST 2009


Hi,

nRk wrote:
> Hi
> 
> I am trying to send Data to a website through "http" using
> "urllib.request" library using the bellow code.
> Response status code contains. 200 (OK) but Response contains
> nothing...
> 
> With same data When I test using C# it working fine.. Response
> having.. some data in xml format.
> But I am using below python code i am getting response only "<HTML></
> HTML>".

This does not mean you are doing it identical to C# here, doesn't it?
Also you might be looking at the defaults in the calls within C#
and some weird expectations on server side.

Also you are requesting XML by sending a payload of XML data,
so you need to make sure you actually use POST and not GET.

I'd start by watching your working application with
strace or wireshark and compare with the data to and fro
from your python application.

Also I believe there should be example code for reading
RSS feeds from python.


> Is there any in my code..
> 
>  req  = urllib2.Request(url) // url is valid url
>  req.add_header('Authorization','AuthSub token="xxxxxxxxxxxxx"')
>  req.add_header('Content-Type','application/atom+xml')
>  req.data=data  // data is having valid xml data
>  r = urllib2.urlopen(req)

> print(r.code) // output 200
> print(r.msg) // output OK
> print(r.read()) //<HTML></HTML>

Regards
Tino


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3241 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20090211/80d9a078/attachment.bin>


More information about the Python-list mailing list