[Python-de] urllib vs. httplib

Dinu Gherman gherman at darwin.in-berlin.de
Wed Aug 28 10:17:56 EDT 2002


Dinu Gherman:

> Nach Benutzung von 
> 
>   tcpwatch.py -L 80:www.photosig.com:80 -s
> 
> und Aufruf in einem Browser von 
> 
>   http://localhost/...
> 
> wird naemlich in der HTTp-Anfrage "Host" zu "localhost",
> was wieder nicht sein darf... und so sehe ich nicht, 
> wie die Cookies wandern. Jemand eine Idee?

Ich habe mal Shane Hathaway direkt gefragt und kopiere 
hier seine Antwort. Auf diese Weise funktioniert es ganz
wunderbar. In meinem vorher angegebenen Programm fehlte
uebrigens nur diese Zeile, um eine identische Ausgabe von
urllib und httplib zu bekommen (python.org schert sich
offenbar nicht drum):

    req.putheader('Host', server)

Gruss und Danke, Thilo!

Dinu


> Dinu Gherman wrote:
> > Hi Shane,
> > 
> > I'm playing with your very nice TCPWatch and have one 
> > question. I'm running it like this:
> > 
> >   python tcpwatch.py -L 80:www.photosig.com:80 -s
> > 
> > and try to monitor the cookie exchange using a normal
> > browser pointed to http://localhost. It seems though,
> > that the HTTP "Host" field remains set to "localhost" 
> > when using TCPWatch as a proxy. Shouldn't it rather 
> > become "www.photosig.com" in this case?
> 
> Interesting point.  -L is supposed to maintain 100% of the 
> data stream, though.  -p (HTTP proxy server) changes the 
> stream almost the way you're asking for, but not quite.  
> Perhaps we need a -p that always forwards to a specific 
> host.  In any case, you can use:
> 
>   python tcpwatch.py -p 3128 -s
> 
> then set your browser to use localhost:3128 as its HTTP 
> proxy server.  You should be able to watch the cookie 
> exchange.
> 
> Shane




More information about the Python-de mailing list