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


Python httplib.HTTPS属性代码示例

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


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

示例1: post_multipart

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPS [as 别名]
def post_multipart(host, selector, fields, files):
	"""
	Post fields and files to an http host as multipart/form-data.
	fields is a sequence of (name, value) elements for regular form fields.
	files is a sequence of (name, filename, value) elements for data to be uploaded as files
	Return the server's response page.
	Reference: https://raw.githubusercontent.com/Gawen/virustotal/master/virustotal.py
	"""
	content_type, body = encode_multipart_formdata(fields, files)
	h = httplib.HTTPS(host)
	h.putrequest('POST', selector)
	h.putheader('content-type', content_type)
	h.putheader('content-length', str(len(body)))
	h.endheaders()
	h.send(body)
	errcode, errmsg, headers = h.getreply()

	return h.file.read()

# Reference: https://raw.githubusercontent.com/Gawen/virustotal/master/virustotal.py 
开发者ID:mertsarica,项目名称:hack4career,代码行数:22,代码来源:vt_mass_uploader.py

示例2: redirect_internal

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPS [as 别名]
def redirect_internal(self, url, fp, errcode, errmsg, headers, data):
        if 'location' in headers:
            newurl = headers['location']
        elif 'uri' in headers:
            newurl = headers['uri']
        else:
            return
        void = fp.read()
        fp.close()
        # In case the server sent a relative URL, join with original:
        newurl = basejoin(self.type + ":" + url, newurl)

        # For security reasons we do not allow redirects to protocols
        # other than HTTP, HTTPS or FTP.
        newurl_lower = newurl.lower()
        if not (newurl_lower.startswith('http://') or
                newurl_lower.startswith('https://') or
                newurl_lower.startswith('ftp://')):
            raise IOError('redirect error', errcode,
                          errmsg + " - Redirection to url '%s' is not allowed" %
                          newurl,
                          headers)

        return self.open(newurl) 
开发者ID:glmcdona,项目名称:meddle,代码行数:26,代码来源:urllib.py

示例3: redirect_internal

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPS [as 别名]
def redirect_internal(self, url, fp, errcode, errmsg, headers, data):
        if 'location' in headers:
            newurl = headers['location']
        elif 'uri' in headers:
            newurl = headers['uri']
        else:
            return
        fp.close()
        # In case the server sent a relative URL, join with original:
        newurl = basejoin(self.type + ":" + url, newurl)

        # For security reasons we do not allow redirects to protocols
        # other than HTTP, HTTPS or FTP.
        newurl_lower = newurl.lower()
        if not (newurl_lower.startswith('http://') or
                newurl_lower.startswith('https://') or
                newurl_lower.startswith('ftp://')):
            raise IOError('redirect error', errcode,
                          errmsg + " - Redirection to url '%s' is not allowed" %
                          newurl,
                          headers)

        return self.open(newurl) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:urllib.py

示例4: test_host_port

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

        # Note that httplib does not accept user:password@ in the host-port.
        for hp in ("www.python.org:abc", "user:password@www.python.org"):
            self.assertRaises(httplib.InvalidURL, httplib.HTTP, hp)

        for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b",
                          8000),
                         ("pypi.python.org:443", "pypi.python.org", 443),
                         ("pypi.python.org", "pypi.python.org", 443),
                         ("pypi.python.org:", "pypi.python.org", 443),
                         ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 443)):
            http = httplib.HTTPS(hp)
            c = http._conn
            if h != c.host:
                self.fail("Host incorrectly parsed: %s != %s" % (h, c.host))
            if p != c.port:
                self.fail("Port incorrectly parsed: %s != %s" % (p, c.host)) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:21,代码来源:test_httplib.py

示例5: _parse_response

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPS [as 别名]
def _parse_response(self, file, sock):
        # read response from input file/socket, and parse it

        p, u = self.getparser()

        while 1:
            if sock:
                response = sock.recv(1024)
            else:
                response = file.read(1024)
            if not response:
                break
            if self.verbose:
                sys.stdout.write("body: %s\n" % repr(response))
            p.feed(response)

        file.close()
        p.close()

        return u.close()

##
# Standard transport class for XML-RPC over HTTPS. 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:25,代码来源:_pydev_xmlrpclib.py

示例6: _parse_response

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPS [as 别名]
def _parse_response(self, file, sock):
        # read response from input file/socket, and parse it

        p, u = self.getparser()

        while 1:
            if sock:
                response = sock.recv(1024)
            else:
                response = file.read(1024)
            if not response:
                break
            if self.verbose:
                print "body:", repr(response)
            p.feed(response)

        file.close()
        p.close()

        return u.close()

##
# Standard transport class for XML-RPC over HTTPS. 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:25,代码来源:xmlrpclib.py

示例7: post_multipart

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPS [as 别名]
def post_multipart(url, fields, files):
    parts = urlparse.urlparse(url)
    scheme = parts[0]
    host = parts[1]
    selector = parts[2]
    content_type, body = encode_multipart_formdata(fields, files)
    if scheme == 'http':
        h = httplib.HTTP(host)
    elif scheme == 'https':
        h = httplib.HTTPS(host)
    else:
        raise ValueError('unknown scheme: ' + scheme)
    h.putrequest('POST', selector)
    h.putheader('content-type', content_type)
    h.putheader('content-length', str(len(body)))
    h.endheaders()
    h.send(body)
    errcode, errmsg, headers = h.getreply()
    return h.file.read() 
开发者ID:yukuku,项目名称:telebot,代码行数:21,代码来源:multipart.py

示例8: build_opener

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPS [as 别名]
def build_opener(*handlers):
    """Create an opener object from a list of handlers.

    The opener will use several default handlers, including support
    for HTTP and FTP.  If there is a ProxyHandler, it must be at the
    front of the list of handlers.  (Yuck.)

    If any of the handlers passed as arguments are subclasses of the
    default handlers, the default handlers will not be used.
    """

    opener = OpenerDirector()
    default_classes = [ProxyHandler, UnknownHandler, HTTPHandler,
                       HTTPDefaultErrorHandler, HTTPRedirectHandler,
                       FTPHandler, FileHandler]
    if hasattr(httplib, 'HTTPS'):
        default_classes.append(HTTPSHandler)
    skip = []
    for klass in default_classes:
        for check in handlers:
            if inspect.isclass(check):
                if issubclass(check, klass):
                    skip.append(klass)
            elif isinstance(check, klass):
                skip.append(klass)
    for klass in skip:
        default_classes.remove(klass)

    for klass in default_classes:
        opener.add_handler(klass())

    for h in handlers:
        if inspect.isclass(h):
            h = h()
        opener.add_handler(h)
    return opener 
开发者ID:war-and-code,项目名称:jawfish,代码行数:38,代码来源:urllib2.py

示例9: https_open

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPS [as 别名]
def https_open(self, req):
            return self.do_open(httplib.HTTPS, req) 
开发者ID:war-and-code,项目名称:jawfish,代码行数:4,代码来源:urllib2.py

示例10: post_multipart

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPS [as 别名]
def post_multipart(host, selector, fields, files):
	content_type, body = encode_multipart_formdata(fields, files)
	h = httplib.HTTPS(host)
	h.putrequest('POST', selector)
	h.putheader('Host', 'www.hybrid-analysis.com')
	h.putheader('User-agent', "VxApi CLI Connector")
	h.putheader('Authorization', "Basic " + vx_authorization)
	h.putheader('content-type', content_type)
	h.putheader('content-length', str(len(body)))
	h.endheaders()
	h.send(body)
	errcode, errmsg, headers = h.getreply()

	return h.file.read() 
开发者ID:mertsarica,项目名称:hack4career,代码行数:16,代码来源:spam_analyzer.py

示例11: vx_check_report

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPS [as 别名]
def vx_check_report(line):
	re1='(.*?)'
	re2='(\\|)'	# DDMMYYYY 1
	re3='(.*?)'	# Variable Name 1
	re4='(\\|)'	# Any Single Character 2
	re5='(.*?)'	# Alphanum 1
	re6='(\\|)'	# Any Single Character 3
	re7='(submitted)'	# Word 1

	rg = re.compile(re1+re2+re3+re4+re5+re6,re.IGNORECASE|re.DOTALL)
	m = rg.search(line.strip())

	if m:
		fname = m.group(3)
		alphanum=m.group(5)
		# Malicious file hash for debugging purposes
		# alphanum = "040c0111aef474d8b7bfa9a7caa0e06b4f1049c7ae8c66611a53fc2599f0b90f"
		host = "www.hybrid-analysis.com"
		selector = "https://wwww.hybrid-analysis.com/api/summary/" + alphanum + "?environmentId=100"
		h = httplib.HTTPS(host)
		h.putrequest('GET', selector)
		h.putheader('Host', 'www.hybrid-analysis.com')
		h.putheader('User-agent', "VxApi CLI Connector")
		h.putheader('Authorization', "Basic " + vx_authorization)
		h.endheaders()

		h.send("")
		errcode, errmsg, headers = h.getreply()

		response = h.file.read()
		
		response_dict = simplejson.loads(response)
		vx_status = str(response_dict.get('response').get('verdict'))
		if vx_status == "None":
			vx_status = "https://www.hybrid-analysis.com/sample/" + alphanum + "?environmentId=100|clean"
		else:
			print "[*] Verdict of", fname + ":", vx_status
			vx_status = "https://www.hybrid-analysis.com/sample/" + alphanum + "?environmentId=100|" + vx_status
		return vx_status 
开发者ID:mertsarica,项目名称:hack4career,代码行数:41,代码来源:spam_analyzer.py

示例12: open

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPS [as 别名]
def open(self):
    if self.scheme == 'http':
      self.__http = httplib.HTTP(self.host, self.port)
    else:
      self.__http = httplib.HTTPS(self.host, self.port) 
开发者ID:XiaoMi,项目名称:galaxy-sdk-python,代码行数:7,代码来源:emrthttpclient.py


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