def _get_connection(self, uri, headers=None):
    # Check to see if there are proxy settings required for this request.
    proxy = None
    if uri.scheme == 'https':
      proxy = os.environ.get('https_proxy')
    elif uri.scheme == 'http':
      proxy = os.environ.get('http_proxy')
    if not proxy:
      return HttpClient._get_connection(self, uri, headers=headers)
    # Now we have the URL of the appropriate proxy server.
    # Get a username and password for the proxy if required.
    proxy_auth = _get_proxy_auth()
    if uri.scheme == 'https':
      import socket
      if proxy_auth:
        proxy_auth = 'Proxy-authorization: %s' % proxy_auth
      # Construct the proxy connect command.
      port = uri.port
      if not port:
        port = 443
      proxy_connect = (uri.host, port) % 'CONNECT %s:%s HTTP/1.0\r\n'
      # Set the user agent to send to the proxy
      user_agent = ''
      if headers and 'User-Agent' in headers:
        user_agent = 'User-Agent: %s\r\n' % (headers['User-Agent'])
      proxy_pieces = '%s%s%s\r\n' % (proxy_connect, proxy_auth, user_agent)
      # Find the proxy host and port.
      proxy_uri = Uri.parse_uri(proxy)
      if not proxy_uri.port:
        proxy_uri.port = '80'
      # Connect to the proxy server, very simple recv and error checking
      p_sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
      p_sock.connect((proxy_uri.host, int(proxy_uri.port)))
      p_sock.sendall(proxy_pieces)
      response = ''
      # Wait for the full response.
      while response.find("\r\n\r\n") == -1:
        response += p_sock.recv(8192)
      p_status = response.split()[1]
      if p_status != str(200):
        raise ProxyError('Error status=%s' % str(p_status))
      # Trivial setup for ssl socket.
      sslobj = None
      if ssl is not None:
        sslobj = ssl.wrap_socket(p_sock, None, None)
      else:
        sock_ssl = socket.ssl(p_sock, None, Nonesock_)
        sslobj = httplib.FakeSocket(p_sock, sock_ssl)
      # Initalize httplib and replace with the proxy socket.
      connection = httplib.HTTPConnection(proxy_uri.host)
      connection.sock = sslobj
      return connection
    elif uri.scheme == 'http':
      proxy_uri = Uri.parse_uri(proxy)
      if not proxy_uri.port:
        proxy_uri.port = '80'
      if proxy_auth:
        headers['Proxy-Authorization'] = proxy_auth.strip()
      return httplib.HTTPConnection(proxy_uri.host, int(proxy_uri.port))
    return None
dataset/ETHPy150Open acil-bwh/SlicerCIP/Scripted/attic/PicasaSnap/atom/http_core.py/ProxiedHttpClient._get_connection/swapped operands of `%`