Exemplo n.º 1
0
def ProcessUrl(service, url, for_proxy=False):
    """Processes a passed URL.  If the URL does not begin with https?, then
  the default value for server is used

  This method is deprecated, use atom.url.parse_url instead.
  """
    if not isinstance(url, atom.url.Url):
        url = atom.url.parse_url(url)

    server = url.host
    ssl = False
    port = 80

    if not server:
        if hasattr(service, 'server'):
            server = service.server
        else:
            server = service
        if not url.protocol and hasattr(service, 'ssl'):
            ssl = service.ssl
        if hasattr(service, 'port'):
            port = service.port
    else:
        if url.protocol == 'https':
            ssl = True
        elif url.protocol == 'http':
            ssl = False
        if url.port:
            port = int(url.port)
        elif port == 80 and ssl:
            port = 443

    return (server, port, ssl, url.get_request_uri())
Exemplo n.º 2
0
 def testGetRequestUri(self):
   url = atom.url.Url(protocol='http', host='example.com', path='/feed')
   url.params['has spaces'] = 'sneaky=values?&!'
   self.assertTrue(url.get_request_uri() == (
       '/feed?has+spaces=sneaky%3Dvalues%3F%26%21'))
   self.assertTrue(url.get_param_string() == (
       'has+spaces=sneaky%3Dvalues%3F%26%21'))
Exemplo n.º 3
0
def ProcessUrl(service, url, for_proxy=False):
  """Processes a passed URL.  If the URL does not begin with https?, then
  the default value for server is used

  This method is deprecated, use atom.url.parse_url instead.
  """
  if not isinstance(url, atom.url.Url):
    url = atom.url.parse_url(url)

  server = url.host
  ssl = False
  port = 80

  if not server:
    if hasattr(service, 'server'):
      server = service.server
    else:
      server = service
    if not url.protocol and hasattr(service, 'ssl'):
      ssl = service.ssl
    if hasattr(service, 'port'):
      port = service.port
  else:
    if url.protocol == 'https':
      ssl = True
    elif url.protocol == 'http':
      ssl = False
    if url.port:
      port = int(url.port)
    elif port == 80 and ssl:
      port = 443

  return (server, port, ssl, url.get_request_uri())
Exemplo n.º 4
0
 def testGetRequestUri(self):
   url = atom.url.Url(protocol='http', host='example.com', path='/feed')
   url.params['has spaces'] = 'sneaky=values?&!'
   self.assert_(url.get_request_uri() == (
       '/feed?has+spaces=sneaky%3Dvalues%3F%26%21'))
   self.assert_(url.get_param_string() == (
       'has+spaces=sneaky%3Dvalues%3F%26%21'))
Exemplo n.º 5
0
 def _get_access_url(self, url):
     proxy = os.environ.get('http_proxy')
     if url.protocol == 'http' and proxy:
         return url.to_string()
     else:
         return url.get_request_uri()
Exemplo n.º 6
0
 def _get_access_url(self, url):
     return url.get_request_uri()
Exemplo n.º 7
0
 def _get_access_url(self, url):
   proxy = os.environ.get('http_proxy')
   if url.protocol == 'http' and proxy:
     return url.to_string()
   else:
     return url.get_request_uri()
Exemplo n.º 8
0
 def _get_access_url(self, url):
   return url.get_request_uri()