urllib POST question

Peter Hansen peter at engcorp.com
Sat Jun 22 03:43:07 CEST 2002


rdack wrote:
> 
> Ben Beuchler <insyte-clp at emt-p.org> wrote in message news:<slrnah4dbq.r77.insyte-clp at petra.bitstream.net>...
> > In article <644f6688.0206200930.48110837 at posting.google.com>, rdack wrote:
> > > i am doing a POST to a server using urllib and it works.
> > > is there some way i can see exactly what is being posted?
> > > a way to get the post object out of urllib - the exact lines it is sending?
> >
> > I'm a big fan of Ethereal...
> > "Sniffing the glue that holds the internet together!"
> >
> > http://www.ethereal.com/
> 
> i am looking into it. seems overkill for wanting to see a few bytes
> that python is generating.
> No way within python to see what urllib intends to send out for the
> POST?

Howzabout this?

>>> import httplib
>>> httplib.HTTPConnection.debuglevel = 1
>>> import urllib
>>> page = urllib.urlopen('http://web.engcorp.com:8080/?test=1').read()
connect: (web.engcorp.com, 8080)
send: 'GET /?test=1 HTTP/1.0\r\n'
send: 'Host: web.engcorp.com:8080\r\n'
send: 'User-agent: Python-urllib/1.15\r\n'
send: '\r\n'
reply: 'HTTP/1.0 200 OK\r\n'
header: Server: Zope/(Zope 2.5.1 (binary release, python 2.1, linux2-x86), pytho
n 2.1.3, linux2) ZServer/1.1b1
header: Date: Sat, 22 Jun 2002 01:25:46 GMT
header: Connection: close
header: Content-Type: text/html
header: Etag:
header: Content-Length: 174
>>> len(page)
174

-python-rocks-ly yr's,
 Peter



More information about the Python-list mailing list