[issue5072] urllib.open sends full URL after GET command instead of local path

Olemis Lang report at bugs.python.org
Tue Jan 27 15:02:46 CET 2009


Olemis Lang <olemis at gmail.com> added the comment:

Actually I am using a proxy hosted in some other machine (i.e. not my 
PC ... sorry, I didnt mention :S ...) I «debugged» urllib and, when 
branching at this point (see below ;) in URLopener.open_http :

{{{
#!python

# urllib,py

    def open_http(self, url, data=None):
        """Use HTTP protocol."""
        import httplib
        user_passwd = None
        proxy_passwd= None
        if isinstance(url, str):             # Branching here !!!!!!!!!!
            host, selector = splithost(url)
            if host:
                user_passwd, host = splituser(host)
                host = unquote(host)
            realhost = host
        else:
            host, selector = url


}}}

url variable is bound to the following binary tuple 

{{{
#!python

('172.18.2.7:3128', 'http://localhost:8000/trac-dev')
}}}

My IP is 172.18.2.99 ... so the `else` branch is the one being executed 

If you need further details ... dont hesitate and ask anything you 
want ;)

PD: What d'u mean when you said?

> Do you have an HTTP proxy? running at the *same* port? (!)

I dont understand this since *I already said* that *I accessed* my Trac 
environment using my web browser (Opera 9.63, I dont know whether this 
is relevant at all ... ), *I sent you* the lines outputted by tracd to 
stdout (or stderr ... I am not very sure right now ... ;) and *I told 
you* that, once I applied the path *I submitted*, everything was *back 
to normal* ...

I dont understand how could all this be possible if I were running 
tracd and an HTTP proxy in the *same* port, or even in case 
`http_proxy` envvar be set to the hostname + port where my Trac 
instance is listening for incoming connections ... 

Anyway ... CMIIW ...

I also checked that immediately before executing the following 
statements ...

{{{
#!python

# urllib,py

        h = httplib.HTTP(host)
        if data is not None:
            h.putrequest('POST', selector)
            h.putheader('Content-Type', 'application/x-www-form-
urlencoded')
            h.putheader('Content-Length', '%d' % len(data))
        else:
            h.putrequest('GET', selector)

}}}

... `selector` is bound to 'http://localhost:8000/trac-dev' ... BTW the 
`else` clause *is the one executed* in this case, and this is 
consistent with tracd reports *I sent before* and is logical since 
`data` arg *is missing* in the code snippet I sent before.

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5072>
_______________________________________


More information about the Python-bugs-list mailing list