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


Python client.HTTPSConnection方法代码示例

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


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

示例1: validate_optional_args

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client 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: httpPost

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import HTTPSConnection [as 别名]
def httpPost(self, url, resource, params ):
        headers = {
            "Accept": "application/json",
            'Content-Type': 'application/x-www-form-urlencoded',
            "User-Agent": "Chrome/39.0.2171.71",
            "KEY":self.accessKey,
            "SIGN":self.getSign(params, self.secretKey)
        }

        conn = httplib.HTTPSConnection(url, timeout=10 )
        tempParams = urllib.parse.urlencode(params) if params else ''

        conn.request("POST", resource, tempParams, headers)
        response = conn.getresponse()
        data = response.read().decode('utf-8')

        conn.close()
        return json.loads(data)

    #---------------------------------------------------------------------- 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:22,代码来源:vngate.py

示例3: http

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import HTTPSConnection [as 别名]
def http(method, url, body=None, headers=None):
    url_info = urlparse.urlparse(url)
    if url_info.scheme == "https":
        con = httplib.HTTPSConnection(url_info.hostname, url_info.port or 443)
    else:
        con = httplib.HTTPConnection(url_info.hostname, url_info.port or 80)

    con.request(method, url_info.path, body, headers)
    response = con.getresponse()

    try:
        if 400 <= response.status < 500:
            raise HttpClientError(response.status, response.reason,
                                  response.read())
        elif 500 <= response.status < 600:
            raise HttpServerError(response.status, response.reason,
                                  response.read())
        else:
            yield response
    finally:
        con.close() 
开发者ID:clarkerubber,项目名称:irwin,代码行数:23,代码来源:fishnet.py

示例4: __init__

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import HTTPSConnection [as 别名]
def __init__(self, moodle_domain: str, moodle_path: str = '/',
                 token: str = '', skip_cert_verify=False):
        """
        Opens a connection to the Moodle system
        """
        if skip_cert_verify:
            context = ssl._create_unverified_context()
        else:
            context = ssl.create_default_context(cafile=certifi.where())
        self.connection = HTTPSConnection(moodle_domain, context=context)

        self.token = token
        self.moodle_domain = moodle_domain
        self.moodle_path = moodle_path

        RequestHelper.stdHeader = {
            'User-Agent': ('Mozilla/5.0 (X11; Linux x86_64)' +
                           ' AppleWebKit/537.36 (KHTML, like Gecko)' +
                           ' Chrome/78.0.3904.108 Safari/537.36'),
            'Content-Type': 'application/x-www-form-urlencoded'
        } 
开发者ID:C0D3D3V,项目名称:Moodle-Downloader-2,代码行数:23,代码来源:request_helper.py

示例5: __make_request

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import HTTPSConnection [as 别名]
def __make_request(self, url, params):
        parse_result = urlparse(url)
        hostname = parse_result.netloc
        context = ssl.SSLContext()
        conn = HTTPSConnection(hostname, None, context=context)
        conn.connect()
        body = urlencode(params)
        headers = {
            'Content-Type': 'application/x-www-form-urlencoded',
            'Content-Length': len(body),
        }
        request_url = f"{parse_result.path}?{parse_result.query}"
        try:
            conn.request("POST", request_url, body, headers)
            response = conn.getresponse()
            data = response.read()
        finally:
            conn.close()
        return data 
开发者ID:djudman,项目名称:evernote-telegram-bot,代码行数:21,代码来源:api.py

示例6: get_dex_auth_token

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import HTTPSConnection [as 别名]
def get_dex_auth_token(address, port, auth_dict, ca_cert_path, proxy_host=None, proxy_port=None,
                       insecure=False, offline=False):
    conn = None
    context = create_security_context(ca_cert_path, insecure=insecure)
    if proxy_host:
        conn = httplib.HTTPSConnection(proxy_host, proxy_port, context=context)
        conn.set_tunnel(address, port)
    else:
        conn = httplib.HTTPSConnection(address, port, context=context)
    headers = {"Content-type": "application/json", "Accept": "text/plain"}
    url = "/authenticate/token?offline=True" if offline else "/authenticate/token"
    conn.request("POST", url, json.dumps(auth_dict), headers)
    response = conn.getresponse()
    data = response.read()
    if response.status == 200:
        dict_data = json.loads(data.decode('utf-8'))
        return dict_data['data']['token']
    else:
        print("Error occurred while trying to get token.")
        sys.exit() 
开发者ID:IntelAI,项目名称:inference-model-manager,代码行数:22,代码来源:common_token.py

示例7: get_dex_auth_url

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import HTTPSConnection [as 别名]
def get_dex_auth_url(address, port, ca_cert_path=None, proxy_host=None, proxy_port=None,
                     insecure=False, offline=False):
    conn = None
    context = create_security_context(ca_cert_path, insecure=insecure)
    if proxy_host:
        conn = httplib.HTTPSConnection(proxy_host, proxy_port, context=context)
        conn.set_tunnel(address, port)
    else:
        conn = httplib.HTTPSConnection(address, port, context=context)
    url = "/authenticate?offline=True" if offline else "/authenticate"
    conn.request("GET", url)
    r1 = conn.getresponse()
    dex_auth_url = r1.getheader('location')
    if dex_auth_url is None:
        print("Can`t get dex url.")
        sys.exit()
    return dex_auth_url 
开发者ID:IntelAI,项目名称:inference-model-manager,代码行数:19,代码来源:common_token.py

示例8: _send_response

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import HTTPSConnection [as 别名]
def _send_response(response_url, response_body):
    try:
        json_response_body = json.dumps(response_body)
    except Exception as e:
        msg = "Failed to convert response to json: {}".format(str(e))
        logger.error(msg, exc_info=True)
        response_body = {'Status': 'FAILED', 'Data': {}, 'Reason': msg}
        json_response_body = json.dumps(response_body)
    logger.debug("CFN response URL: {}".format(response_url))
    logger.debug(json_response_body)
    headers = {'content-type': '', 'content-length': str(len(json_response_body))}
    split_url = urlsplit(response_url)
    host = split_url.netloc
    url = urlunsplit(("", "", *split_url[2:]))
    while True:
        try:
            connection = HTTPSConnection(host)
            connection.request(method="PUT", url=url, body=json_response_body, headers=headers)
            response = connection.getresponse()
            logger.info("CloudFormation returned status code: {}".format(response.reason))
            break
        except Exception as e:
            logger.error("Unexpected failure sending response to CloudFormation {}".format(e), exc_info=True)
            time.sleep(5) 
开发者ID:aws-cloudformation,项目名称:custom-resource-helper,代码行数:26,代码来源:utils.py

示例9: validate_optional_args

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client 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:PaperDashboard,项目名称:shadowsocks,代码行数:18,代码来源:speedtest.py

示例10: request_oneview

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import HTTPSConnection [as 别名]
def request_oneview(oneview_ip, rest_url):
    try:
        connection = HTTPSConnection(
            oneview_ip, context=ssl.SSLContext(ssl.PROTOCOL_TLSv1_2))

        connection.request(
            method='GET', url=rest_url,
            headers={'Content-Type': 'application/json',
                     'X-API-Version': config.get_api_version()}
            )

        response = connection.getresponse()

        if response.status != status.HTTP_200_OK:
            message = "OneView is unreachable at {}".format(
                oneview_ip)
            raise OneViewRedfishException(message)

        text_response = response.read().decode('UTF-8')
        json_response = json.loads(text_response)

        return json_response
    finally:
        connection.close() 
开发者ID:HewlettPackard,项目名称:oneview-redfish-toolkit,代码行数:26,代码来源:connection.py

示例11: __init__

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client 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

示例12: plugin

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import HTTPSConnection [as 别名]
def plugin(srv, item):
    srv.logging.debug("*** MODULE=%s: service=%s, target=%s", __file__, item.service, item.target)

    apikey = item.addrs[0]

    title = item.get('title', srv.SCRIPTNAME)
    message = item.message

    http_handler = HTTPSConnection("pushalot.com")

    data = {'AuthorizationToken': apikey,
            'Title': title.encode('utf-8'),
            'Body': message.encode('utf-8')
            }

    try:
        http_handler.request("POST", "/api/sendmessage",
                             headers={'Content-type': "application/x-www-form-urlencoded"},
                             body=urlencode(data)
                             )
    except (SSLError, HTTPException) as e:
        srv.logging.warn("Pushalot notification failed: %s" % str(e))
        return False

    response = http_handler.getresponse()

    srv.logging.debug("Reponse: %s, %s" % (response.status, response.reason))

    return True 
开发者ID:jpmens,项目名称:mqttwarn,代码行数:31,代码来源:pushalot.py

示例13: get_https_connection

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import HTTPSConnection [as 别名]
def get_https_connection(self, host, timeout=300):
            """Returns a HTTPSConnection"""
            return HTTPSConnection(
                host,
                key_file=self._ssl_config['key'],
                cert_file=self._ssl_config['cert']
            ) 
开发者ID:LuciferJack,项目名称:python-mysql-pool,代码行数:9,代码来源:connection.py

示例14: __init__

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import HTTPSConnection [as 别名]
def __init__(self, HTTPConnection=httplib.HTTPConnection,
                 HTTPSConnection=httplib.HTTPSConnection):
        self.HTTPConnection = HTTPConnection
        self.HTTPSConnection = HTTPSConnection 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:6,代码来源:client.py

示例15: _timeout_supported

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import HTTPSConnection [as 别名]
def _timeout_supported(self, ConnClass):
        if sys.version_info < (2, 7) and ConnClass in (
            httplib.HTTPConnection, httplib.HTTPSConnection): # pragma: no cover
            return False
        return True 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:7,代码来源:client.py


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