wsgi/request.py
changeset 9755 566d90bdc565
parent 9741 b6cc9da206df
child 9821 2077c8da1893
equal deleted inserted replaced
9741:b6cc9da206df 9755:566d90bdc565
   101 
   101 
   102         return path
   102         return path
   103 
   103 
   104     ## wsgi request helpers ###################################################
   104     ## wsgi request helpers ###################################################
   105 
   105 
   106     def instance_uri(self):
       
   107         """Return the instance's base URI (no PATH_INFO or QUERY_STRING)
       
   108 
       
   109         see python2.5's wsgiref.util.instance_uri code
       
   110         """
       
   111         environ = self.environ
       
   112         url = environ['wsgi.url_scheme'] + '://'
       
   113         if environ.get('HTTP_HOST'):
       
   114             url += environ['HTTP_HOST']
       
   115         else:
       
   116             url += environ['SERVER_NAME']
       
   117             if environ['wsgi.url_scheme'] == 'https':
       
   118                 if environ['SERVER_PORT'] != '443':
       
   119                     url += ':' + environ['SERVER_PORT']
       
   120             else:
       
   121                 if environ['SERVER_PORT'] != '80':
       
   122                     url += ':' + environ['SERVER_PORT']
       
   123         url += quote(environ.get('SCRIPT_NAME') or '/')
       
   124         return url
       
   125 
       
   126     def get_full_path(self):
       
   127         return '%s%s' % (self.path, self.environ.get('QUERY_STRING', '') and ('?' + self.environ.get('QUERY_STRING', '')) or '')
       
   128 
       
   129     def is_secure(self):
   106     def is_secure(self):
   130         return self.environ['wsgi.url_scheme'] == 'https'
   107         return self.environ['wsgi.url_scheme'] == 'https'
   131 
   108 
   132     def get_posted_data(self):
   109     def get_posted_data(self):
   133         # The WSGI spec says 'QUERY_STRING' may be absent.
   110         # The WSGI spec says 'QUERY_STRING' may be absent.