[Python-Dev] Suggestion: URL splitter that returns host, port, request URL

Hamish Lawson hbl at st-andrews.ac.uk
Wed Feb 18 12:51:41 EST 2004

The HTTP clients provided by many libraries (httplib in the Standard 
Library, asynchttp, Twisted) do not deal with absolute URLs but instead 
with the three component parts of host, port, and request URL. However 
these are not the parts returned by either urlparse.urlsplit or 
urlparse.urlparse. I therefore suggest it might be useful to have in the 
Standard Library a function that splits an absolute URL into host, port, 
and request URL. So for the following URL:


the function would return

     ("www.python.org", 80, "/cgi-bin/moinmoin/FrontPage?action=edit")

An optional parameter could specify which port to use as default.

Hamish Lawson

More information about the Python-Dev mailing list