[Web-SIG] [proposal] wsgiref.util.abs_url

Manlio Perillo manlio_perillo at libero.it
Fri May 2 23:03:43 CEST 2008


Hi.

I think that a function like (not tested):

def abs_url(environ, relative_url):
     """Return the absolute url"""
     url = environ['wsgi.url_scheme']+'://'
     from urllib import quote

     if environ.get('HTTP_HOST'):
         url += environ['HTTP_HOST']
     else:
         url += environ['SERVER_NAME']

         if environ['wsgi.url_scheme'] == 'https':
             if environ['SERVER_PORT'] != '443':
                 url += ':' + environ['SERVER_PORT']
         else:
             if environ['SERVER_PORT'] != '80':
                 url += ':' + environ['SERVER_PORT']

     url += quote(relative_url)
     return url



would be an useful addition to the wsgiref.util module.


What do you think?


Thanks   Manlio Perillo


More information about the Web-SIG mailing list