当前位置: 首页>>代码示例>>Python>>正文


Python httplib.HTTPSConnection方法代码示例

本文整理汇总了Python中httplib.HTTPSConnection方法的典型用法代码示例。如果您正苦于以下问题:Python httplib.HTTPSConnection方法的具体用法?Python httplib.HTTPSConnection怎么用?Python httplib.HTTPSConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在httplib的用法示例。


在下文中一共展示了httplib.HTTPSConnection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: validate_optional_args

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPSConnection [as 别名]
def validate_optional_args(args):
	"""Check if an argument was provided that depends on a module that may
	not be part of the Python standard library.

	If such an argument is supplied, and the module does not exist, exit
	with an error stating which module is missing.
	"""
	optional_args = {
		'json': ('json/simplejson python module', json),
		'secure': ('SSL support', HTTPSConnection),
	}

	for arg, info in optional_args.items():
		if getattr(args, arg, False) and info[1] is None:
			raise SystemExit('%s is not installed. --%s is '
							 'unavailable' % (info[0], arg)) 
开发者ID:NatanaelAntonioli,项目名称:L.E.S.M.A,代码行数:18,代码来源:L.E.S.M.A. - Fabrica de Noobs Speedtest.py

示例2: _dispatch_request

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPSConnection [as 别名]
def _dispatch_request(self, path, body):
    """Proxies GET request to discovery service API.

    Args:
      path: A string containing the URL path relative to discovery service.
      body: A string containing the HTTP POST request body.

    Returns:
      HTTP response body or None if it failed.
    """
    full_path = self._DISCOVERY_API_PATH_PREFIX + path
    headers = {'Content-type': 'application/json'}
    connection = httplib.HTTPSConnection(self._DISCOVERY_PROXY_HOST)
    try:
      connection.request('POST', full_path, body, headers)
      response = connection.getresponse()
      response_body = response.read()
      if response.status != 200:
        logging.error('Discovery API proxy failed on %s with %d.\r\n'
                      'Request: %s\r\nResponse: %s',
                      full_path, response.status, body, response_body)
        return None
      return response_body
    finally:
      connection.close() 
开发者ID:elsigh,项目名称:browserscope,代码行数:27,代码来源:discovery_api_proxy.py

示例3: get_static_file

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPSConnection [as 别名]
def get_static_file(self, path):
    """Returns static content via a GET request.

    Args:
      path: A string containing the URL path after the domain.

    Returns:
      A tuple of (response, response_body):
        response: A HTTPResponse object with the response from the static
          proxy host.
        response_body: A string containing the response body.
    """
    connection = httplib.HTTPSConnection(self._STATIC_PROXY_HOST)
    try:
      connection.request('GET', path, None, {})
      response = connection.getresponse()
      response_body = response.read()
    finally:
      connection.close()
    return response, response_body 
开发者ID:elsigh,项目名称:browserscope,代码行数:22,代码来源:discovery_api_proxy.py

示例4: _DispatchRequest

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPSConnection [as 别名]
def _DispatchRequest(self, path, body):
    """Proxies GET request to discovery service API.

    Args:
      path: URL path relative to discovery service.
      body: HTTP POST request body.

    Returns:
      HTTP response body or None if it failed.
    """
    full_path = self._DISCOVERY_API_PATH_PREFIX + path
    headers = {'Content-type': 'application/json'}
    connection = httplib.HTTPSConnection(self._DISCOVERY_PROXY_HOST)
    try:
      connection.request('POST', full_path, body, headers)
      response = connection.getresponse()
      response_body = response.read()
      if response.status != 200:
        logging.error('Discovery API proxy failed on %s with %d.\r\n'
                      'Request: %s\r\nResponse: %s',
                      full_path, response.status, body, response_body)
        return None
      return response_body
    finally:
      connection.close() 
开发者ID:elsigh,项目名称:browserscope,代码行数:27,代码来源:dev_appserver_apiserver.py

示例5: GetStaticFile

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPSConnection [as 别名]
def GetStaticFile(self, path):
    """Returns static content via a GET request.

    Args:
      path: URL path after the domain.

    Returns:
      Tuple of (response, response_body):
        response: HTTPResponse object.
        response_body: Response body as string.
    """
    connection = httplib.HTTPSConnection(self._STATIC_PROXY_HOST)
    try:
      connection.request('GET', path, None, {})
      response = connection.getresponse()
      response_body = response.read()
    finally:
      connection.close()
    return response, response_body 
开发者ID:elsigh,项目名称:browserscope,代码行数:21,代码来源:dev_appserver_apiserver.py

示例6: __init__

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPSConnection [as 别名]
def __init__(self, target):
        # Target comes as protocol://target:port/path
        self.target = target
        proto, host, path = target.split(':')
        host = host[2:]
        self.path = '/' + path.split('/', 1)[1]
        if proto.lower() == 'https':
            #Create unverified (insecure) context
            try:
                uv_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
                self.session = HTTPSConnection(host,context=uv_context)
            except AttributeError:
                #This does not exist on python < 2.7.11
                self.session = HTTPSConnection(host)
        else:
            self.session = HTTPConnection(host)
        self.lastresult = None 
开发者ID:joxeankoret,项目名称:CVE-2017-7494,代码行数:19,代码来源:httprelayclient.py

示例7: test_host_port

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPSConnection [as 别名]
def test_host_port(self):
        # Check invalid host_port

        for hp in ("www.python.org:abc", "user:password@www.python.org"):
            self.assertRaises(httplib.InvalidURL, httplib.HTTPSConnection, hp)

        for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000",
                          "fe80::207:e9ff:fe9b", 8000),
                         ("www.python.org:443", "www.python.org", 443),
                         ("www.python.org:", "www.python.org", 443),
                         ("www.python.org", "www.python.org", 443),
                         ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 443),
                         ("[fe80::207:e9ff:fe9b]:", "fe80::207:e9ff:fe9b",
                             443)):
            c = httplib.HTTPSConnection(hp)
            self.assertEqual(h, c.host)
            self.assertEqual(p, c.port) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_httplib.py

示例8: read

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPSConnection [as 别名]
def read(self, url):
        self.url = url
        u = urlparse.urlparse(url)
        self.domain = u.netloc
        try:
            connection = httplib.HTTPConnection(u.netloc) if u.scheme == 'http' else httplib.HTTPSConnection(u.netloc)
            connection.request("GET",u.geturl(), headers=REQUEST_HEADERS)
            response = connection.getresponse()
        except:
            self.error = "cannot read url"
            return

        try:
            r = response.read()
        except:
            self.error = "cannot read"
            return

        self.id = bitcoin.sha256(r)[0:16].encode('hex')
        filename = os.path.join(self.dir_path, self.id)
        with open(filename,'w') as f:
            f.write(r)

        return self.parse(r) 
开发者ID:mazaclub,项目名称:encompass,代码行数:26,代码来源:paymentrequest.py

示例9: do_buy

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPSConnection [as 别名]
def do_buy(credentials, amount):
    conn = httplib.HTTPSConnection('coinbase.com')
    credentials.authorize(conn)
    params = {
        'qty': float(amount)/SATOSHIS_PER_BTC,
        'agree_btc_amount_varies': False
    }
    resp = conn.auth_request('POST', '/api/v1/buys', urlencode(params), None)

    if resp.status != 200:
        message(_('Error, could not buy bitcoin'))
        return
    content = json.loads(resp.read())
    if content['success']:
        message(_('Success!\n') + content['transfer']['description'])
    else:
        if content['errors']:
            message(_('Error: ') + string.join(content['errors'], '\n'))
        else:
            message(_('Error, could not buy bitcoin')) 
开发者ID:mazaclub,项目名称:encompass,代码行数:22,代码来源:coinbase_buyback.py

示例10: main

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPSConnection [as 别名]
def main(args):
    """Request a Google ID token using a JWT."""
    params = urllib.urlencode({
        'grant_type': 'urn:ietf:params:oauth:grant-type:jwt-bearer',
        'assertion': generate_jwt(args)})
    headers = {"Content-Type": "application/x-www-form-urlencoded"}
    conn = httplib.HTTPSConnection("www.googleapis.com")
    conn.request("POST", "/oauth2/v4/token", params, headers)
    res = json.loads(conn.getresponse().read())
    conn.close()
    return res['id_token'] 
开发者ID:cloudendpoints,项目名称:endpoints-tools,代码行数:13,代码来源:generate-google-id-jwt.py

示例11: __init__

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPSConnection [as 别名]
def __init__(
        self,
        host,
        port=None,
        key_file=None,
        cert_file=None,
        strict=None,
        timeout=None,
        proxy_info=None,
        ca_certs=None,
        disable_ssl_certificate_validation=False,
        ssl_version=None,
    ):
        httplib.HTTPSConnection.__init__(
            self,
            host,
            port=port,
            key_file=key_file,
            cert_file=cert_file,
            strict=strict,
            timeout=timeout,
        )
        self._fetch = _new_fixed_fetch(not disable_ssl_certificate_validation)


# Use a different connection object for Google App Engine Standard Environment. 
开发者ID:remg427,项目名称:misp42splunk,代码行数:28,代码来源:__init__.py

示例12: paste

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPSConnection [as 别名]
def paste(self, content, lexer=None, ttl=None, key=None):
        """Create a new paste.

        Args:
          content: string of text to paste
          lexer: lexer to use (defaults to text)
          ttl: time-to-live in days (defaults to 30)
          key: encrypt paste with this key; if not specified, paste is not
               encrypted

        Returns:
          Paste object
        """
        if lexer is None:
            lexer = DEFAULT_LEXER
        if ttl is None:
            ttl = DEFAULT_TTL

        if self._scheme == "https":
            self._conn = httplib.HTTPSConnection(self._netloc)
        else:
            self._conn = httplib.HTTPConnection(self._netloc)

        headers = {"Content-type": "application/x-www-form-urlencoded",
                   "Accept": "text/plain"}
        params = {"lexer": lexer,
                  "content": content,
                  "ttl": int(ttl * 86400)}
        if key is not None:
            params["encrypt"] = "checked"
            params["key"] = key

        self._lock.acquire()
        self._conn.request("POST", "/submit", urllib.urlencode(params), headers)
        response = self._conn.getresponse()
        self._lock.release()
        return self._make_paste(response, content, lexer) 
开发者ID:sockeye44,项目名称:instavpn,代码行数:39,代码来源:pastee.py

示例13: __init__

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPSConnection [as 别名]
def __init__(self, proxytype, proxyaddr, proxyport=None, rdns=True, username=None, password=None, *args, **kwargs):
        self.proxyargs = (proxytype, proxyaddr, proxyport, rdns, username, password)
        httplib.HTTPSConnection.__init__(self, *args, **kwargs) 
开发者ID:vulscanteam,项目名称:vulscan,代码行数:5,代码来源:sockshandler.py

示例14: prepare_discovery_request

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPSConnection [as 别名]
def prepare_discovery_request(self, status_code, body):
    self.mox.StubOutWithMock(httplib.HTTPSConnection, 'request')
    self.mox.StubOutWithMock(httplib.HTTPSConnection, 'getresponse')
    self.mox.StubOutWithMock(httplib.HTTPSConnection, 'close')

    httplib.HTTPSConnection.request(mox.IsA(basestring), mox.IsA(basestring),
                                    mox.IgnoreArg(), mox.IsA(dict))
    httplib.HTTPSConnection.getresponse().AndReturn(
        test_utils.MockConnectionResponse(status_code, body))
    httplib.HTTPSConnection.close() 
开发者ID:elsigh,项目名称:browserscope,代码行数:12,代码来源:discovery_api_proxy_test.py

示例15: __init__

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPSConnection [as 别名]
def __init__(self, proxytype, proxyaddr, proxyport = None, rdns = True, username = None, password = None, *args, **kwargs):
		self.proxyargs = (proxytype, proxyaddr, proxyport, rdns, username, password)
		httplib.HTTPSConnection.__init__(self, *args, **kwargs) 
开发者ID:moneymaker365,项目名称:plugin.video.ustvvod,代码行数:5,代码来源:connection.py


注:本文中的httplib.HTTPSConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。