[Tutor] requests/responses from urllib2

Kent Johnson kent37 at tds.net
Mon Aug 11 12:54:40 CEST 2008


On Mon, Aug 11, 2008 at 2:52 AM, Eric Abrahamsen
<eric at ericabrahamsen.net> wrote:
The python docs say that urllib2 requires the
> socket library to work, so I assume it's a socket of some sort, but I don't
> really understand how that socket is addressed, from the point of view of
> the third-party server that is receiving my urllib2 request, and returning
> the response. Where does it appear to be coming from?

The request comes from your web server, that is what the other server will see.

> If my web server
> (lighttpd in this case) is set to listen on a particular port, is there any
> way that it can 'see' that traffic and interact with it, or is it purely
> between the python library and the outside world?

I'm not sure if you want to see the traffic coming in from your users,
or the traffic from your server to the third-party server. I don't
know what kind of interaction you want, either.

Most web frameworks have a way to log the requests they receive. There
may be a debug mode that includes request and response headers in the
log.

You could turn on debug mode in httplib, this will give you details
about the outgoing traffic. I don't think it will affect the incoming
traffic but I'm not certain. See
http://personalpages.tds.net/~kent37/kk/00010.html#e10debugging

Kent


More information about the Tutor mailing list