[Tutor] requests/responses from urllib2

Eric Abrahamsen eric at ericabrahamsen.net
Mon Aug 11 08:52:07 CEST 2008


I've got a question about the way urllib2 makes its requests. If I've  
got a python web framework running behind a web server, and that  
framework uses urllib2 to make a request to another server, how does  
that traffic go in and out of my server machine? 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? 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?

Thanks for any enlightenment!

Eric


More information about the Tutor mailing list