當前位置: 首頁>>代碼示例>>Python>>正文


Python socks.PROXY_TYPE_HTTP屬性代碼示例

本文整理匯總了Python中httplib2.socks.PROXY_TYPE_HTTP屬性的典型用法代碼示例。如果您正苦於以下問題:Python socks.PROXY_TYPE_HTTP屬性的具體用法?Python socks.PROXY_TYPE_HTTP怎麽用?Python socks.PROXY_TYPE_HTTP使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在httplib2.socks的用法示例。


在下文中一共展示了socks.PROXY_TYPE_HTTP屬性的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from httplib2 import socks [as 別名]
# 或者: from httplib2.socks import PROXY_TYPE_HTTP [as 別名]
def __init__(
        self,
        proxy_type,
        proxy_host,
        proxy_port,
        proxy_rdns=True,
        proxy_user=None,
        proxy_pass=None,
        proxy_headers=None,
    ):
        """Args:

          proxy_type: The type of proxy server.  This must be set to one of
          socks.PROXY_TYPE_XXX constants.  For example:  p =
          ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, proxy_host='localhost',
          proxy_port=8000)
          proxy_host: The hostname or IP address of the proxy server.
          proxy_port: The port that the proxy server is running on.
          proxy_rdns: If True (default), DNS queries will not be performed
          locally, and instead, handed to the proxy to resolve.  This is useful
          if the network does not allow resolution of non-local names. In
          httplib2 0.9 and earlier, this defaulted to False.
          proxy_user: The username used to authenticate with the proxy server.
          proxy_pass: The password used to authenticate with the proxy server.
          proxy_headers: Additional or modified headers for the proxy connect
          request.
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass
        self.proxy_headers = proxy_headers 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:36,代碼來源:__init__.py

示例2: __init__

# 需要導入模塊: from httplib2 import socks [as 別名]
# 或者: from httplib2.socks import PROXY_TYPE_HTTP [as 別名]
def __init__(self, proxy_type, proxy_host, proxy_port,
                 proxy_rdns=True, proxy_user=None, proxy_pass=None):
        """
        Args:
          proxy_type: The type of proxy server.  This must be set to one of
          socks.PROXY_TYPE_XXX constants.  For example:

            p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
              proxy_host='localhost', proxy_port=8000)

          proxy_host: The hostname or IP address of the proxy server.

          proxy_port: The port that the proxy server is running on.

          proxy_rdns: If True (default), DNS queries will not be performed
          locally, and instead, handed to the proxy to resolve.  This is useful
          if the network does not allow resolution of non-local names.  In
          httplib2 0.9 and earlier, this defaulted to False.

          proxy_user: The username used to authenticate with the proxy server.

          proxy_pass: The password used to authenticate with the proxy server.
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass 
開發者ID:mortcanty,項目名稱:earthengine,代碼行數:31,代碼來源:__init__.py

示例3: proxy_info_from_url

# 需要導入模塊: from httplib2 import socks [as 別名]
# 或者: from httplib2.socks import PROXY_TYPE_HTTP [as 別名]
def proxy_info_from_url(url, method='http'):
    """
    Construct a ProxyInfo from a URL (such as http_proxy env var)
    """
    url = urlparse.urlparse(url)
    username = None
    password = None
    port = None
    if '@' in url[1]:
        ident, host_port = url[1].split('@', 1)
        if ':' in ident:
            username, password = ident.split(':', 1)
        else:
            password = ident
    else:
        host_port = url[1]
    if ':' in host_port:
        host, port = host_port.split(':', 1)
    else:
        host = host_port

    if port:
        port = int(port)
    else:
        port = dict(https=443, http=80)[method]

    proxy_type = 3 # socks.PROXY_TYPE_HTTP
    return ProxyInfo(
        proxy_type = proxy_type,
        proxy_host = host,
        proxy_port = port,
        proxy_user = username or None,
        proxy_pass = password or None,
    ) 
開發者ID:mortcanty,項目名稱:earthengine,代碼行數:36,代碼來源:__init__.py

示例4: testSimpleProxy

# 需要導入模塊: from httplib2 import socks [as 別名]
# 或者: from httplib2.socks import PROXY_TYPE_HTTP [as 別名]
def testSimpleProxy(self):
        proxy_info = httplib2.ProxyInfo(socks.PROXY_TYPE_HTTP,
                                        'localhost', self.proxyport)
        client = httplib2.Http(proxy_info=proxy_info)
        src = 'miniserver.py'
        response, body = client.request('http://localhost:%d/%s' %
                                        (self.port, src))
        self.assertEqual(response.status, 200)
        self.assertEqual(body, open(os.path.join(miniserver.HERE, src)).read())
        lf = open(self.logfile).read()
        expect = ('Established connection to host "127.0.0.1" '
                  'using file descriptor')
        self.assertTrue(expect in lf,
                        'tinyproxy did not proxy a request for miniserver') 
開發者ID:mortcanty,項目名稱:earthengine,代碼行數:16,代碼來源:test_proxies.py

示例5: __init__

# 需要導入模塊: from httplib2 import socks [as 別名]
# 或者: from httplib2.socks import PROXY_TYPE_HTTP [as 別名]
def __init__(self, proxy_type, proxy_host, proxy_port,
                 proxy_rdns=True, proxy_user=None, proxy_pass=None, proxy_headers=None):
        """
        Args:
          proxy_type: The type of proxy server.  This must be set to one of
          socks.PROXY_TYPE_XXX constants.  For example:

            p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
              proxy_host='localhost', proxy_port=8000)

          proxy_host: The hostname or IP address of the proxy server.

          proxy_port: The port that the proxy server is running on.

          proxy_rdns: If True (default), DNS queries will not be performed
          locally, and instead, handed to the proxy to resolve.  This is useful
          if the network does not allow resolution of non-local names.  In
          httplib2 0.9 and earlier, this defaulted to False.

          proxy_user: The username used to authenticate with the proxy server.

          proxy_pass: The password used to authenticate with the proxy server.

          proxy_headers: Additional or modified headers for the proxy connect request.
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass
        self.proxy_headers = proxy_headers 
開發者ID:skarlekar,項目名稱:faces,代碼行數:34,代碼來源:__init__.py

示例6: proxy_info_from_url

# 需要導入模塊: from httplib2 import socks [as 別名]
# 或者: from httplib2.socks import PROXY_TYPE_HTTP [as 別名]
def proxy_info_from_url(url, method='http'):
    """
    Construct a ProxyInfo from a URL (such as http_proxy env var)
    """
    url = urlparse.urlparse(url)
    username = None
    password = None
    port = None
    if '@' in url[1]:
        ident, host_port = url[1].split('@', 1)
        if ':' in ident:
            username, password = ident.split(':', 1)
        else:
            password = ident
    else:
        host_port = url[1]
    if ':' in host_port:
        host, port = host_port.split(':', 1)
    else:
        host = host_port

    if port:
        port = int(port)
    else:
        port = dict(https=443, http=80)[method]

    proxy_type = 3 # socks.PROXY_TYPE_HTTP
    return ProxyInfo(
        proxy_type = proxy_type,
        proxy_host = host,
        proxy_port = port,
        proxy_user = username or None,
        proxy_pass = password or None,
        proxy_headers = None,
    ) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:37,代碼來源:__init__.py

示例7: __init__

# 需要導入模塊: from httplib2 import socks [as 別名]
# 或者: from httplib2.socks import PROXY_TYPE_HTTP [as 別名]
def __init__(self, proxy_type, proxy_host, proxy_port,
                 proxy_rdns=None, proxy_user=None, proxy_pass=None):
        """The parameter proxy_type must be set to one of socks.PROXY_TYPE_XXX
        constants. For example:

        p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
            proxy_host='localhost', proxy_port=8000)
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass 
開發者ID:Schibum,項目名稱:sndlatr,代碼行數:16,代碼來源:__init__.py

示例8: testSimpleProxy

# 需要導入模塊: from httplib2 import socks [as 別名]
# 或者: from httplib2.socks import PROXY_TYPE_HTTP [as 別名]
def testSimpleProxy(self):
        proxy_info = httplib2.ProxyInfo(
            socks.PROXY_TYPE_HTTP, "localhost", self.proxyport
        )
        client = httplib2.Http(proxy_info=proxy_info)
        src = "miniserver.py"
        response, body = client.request("http://localhost:%d/%s" % (self.port, src))
        self.assertEqual(response.status, 200)
        self.assertEqual(body, open(os.path.join(miniserver.HERE, src)).read())
        lf = open(self.logfile).read()
        expect = 'Established connection to host "127.0.0.1" ' "using file descriptor"
        self.assertTrue(
            expect in lf, "tinyproxy did not proxy a request for miniserver"
        ) 
開發者ID:fniephaus,項目名稱:alfred-gmail,代碼行數:16,代碼來源:test_proxies.py

示例9: __init__

# 需要導入模塊: from httplib2 import socks [as 別名]
# 或者: from httplib2.socks import PROXY_TYPE_HTTP [as 別名]
def __init__(self, consumer_key, consumer_secret, token_key, token_secret):
        consumer = Consumer(key=consumer_key, secret=consumer_secret)
        token = Token(key=token_key, secret=token_secret)

        proxy_info = None
        if hasattr(settings, 'PROXY_HOST') and \
                hasattr(settings, 'PROXY_PORT'):
            proxy_info = ProxyInfo(
                proxy_type=PROXY_TYPE_HTTP,
                proxy_host=settings.PROXY_HOST,
                proxy_port=settings.PROXY_PORT)
        self.client = Client(
            consumer=consumer,
            token=token,
            proxy_info=proxy_info) 
開發者ID:Gandi,項目名稱:baobab,代碼行數:17,代碼來源:authentication.py


注:本文中的httplib2.socks.PROXY_TYPE_HTTP屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。