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


Python httplib.HTTPConnection类代码示例

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


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

示例1: GET

 def GET(self, req):
     """Handle the query request."""
     conn = HTTPConnection('%s:%s' % (self.mds_ip, self.mds_port))
     headers = req.params
     conn.request('GET', req.path, headers=headers)
     resp = conn.getresponse()
     return Response(request=req, body=resp.read(), content_type=resp.getheader('Content-Type'))
开发者ID:2015-ucsc-hp,项目名称:swift,代码行数:7,代码来源:metadata.py

示例2: POST

 def POST(self, env):
     """Handle posts dealing with metadata alteration"""
     req = Request(env)
     conn = HTTPConnection('%s:%s' % (self.mds_ip, self.mds_port))
     headers = req.params
     version, acc, con, obj = split_path(req.path, 1, 4, True)
     if not con:
         try:
             info = get_account_info(env, self.app)
             if info:
                 stor_policy = info['storage_policy']
                 headers['storage_policy'] = stor_policy
         except:
             pass
     else:
         try:
             info = get_container_info(env, self.app)
             if info:
                 stor_policy = info['storage_policy']
                 headers['storage_policy'] = stor_policy
         except:
             pass
     conn.request('POST', req.path, headers=headers)
     resp = conn.getresponse()
     #confirm response then pass along the request
     return self.app
开发者ID:2015-ucsc-hp,项目名称:swift,代码行数:26,代码来源:metadata.py

示例3: COPY

 def COPY(self, env):
     """Eliminate metadata for deleted objects"""
     req = Request(env)
     conn = HTTPConnection('%s:%s' % (self.mds_ip, self.mds_port))
     headers = req.params
     conn.request('COPY', req.path, headers=headers)
     resp = conn.getresponse()
     #confirm response then pass along the request
     return self.app
开发者ID:2015-ucsc-hp,项目名称:swift,代码行数:9,代码来源:metadata.py

示例4: http_connect

def http_connect(host, method, path, headers=None):
    conn = HTTPConnection(host)
    conn.path = path
    conn.putrequest(method, path)
    if headers:
        for header, value in headers.items():
            if isinstance(value, (list, tuple)):
                for k in value:
                    conn.putheader(header, str(k))
            else:
                conn.putheader(header, str(value))
    conn.endheaders()
    return conn
开发者ID:carriercomm,项目名称:oiopy,代码行数:13,代码来源:http.py

示例5: sendData

 def sendData(self, metaList, data_type, server_ip, server_port):
     ip = server_ip
     port = server_port
     updatedData = json.dumps(metaList)
     headers = {'user-agent': data_type}
     with ConnectionTimeout(self.conn_timeout):
         try:
             conn = HTTPConnection('%s:%s' % (ip, port))
             conn.request('PUT', '/', headers=headers, body=updatedData)
             resp = conn.getresponse()
             return resp
         except (Exception, Timeout):
             return HTTP_INTERNAL_SERVER_ERROR
开发者ID:2015-ucsc-hp,项目名称:swift,代码行数:13,代码来源:utils.py

示例6: PUT

 def PUT(self, env):
     """Handle PUT requests related to metadata"""
     req = Request(env)
     conn = HTTPConnection('%s:%s' % (self.mds_ip, self.mds_port))
     headers = req.params
     try:
         info = get_container_info(env, self.app)
         if info:
             stor_policy = info['storage_policy']
             headers['storage_policy'] = stor_policy
     except:
         pass
     conn.request('PUT', req.path, headers=headers)
     resp = conn.getresponse()
     return self.app
开发者ID:2015-ucsc-hp,项目名称:swift,代码行数:15,代码来源:metadata.py

示例7: getresponse

 def getresponse(self):
     response = HTTPConnection.getresponse(self)
     logging.debug(("HTTP PERF: %(time).5f seconds to %(method)s "
                     "%(host)s:%(port)s %(path)s)"),
        {'time': time.time() - self._connected_time, 'method': self._method,
         'host': self.host, 'port': self.port, 'path': self._path})
     return response
开发者ID:AsherBond,项目名称:colony,代码行数:7,代码来源:bufferedhttp.py

示例8: http_connect

def http_connect(host, method, path, headers=None):
    conn = HTTPConnection(host)
    conn.path = path
    conn.putrequest(method, path)
    if headers:
        for header, value in headers.iteritems():
            conn.putheader(header, str(value))
    conn.endheaders()
    return conn
开发者ID:fvennetier,项目名称:oiopy,代码行数:9,代码来源:http.py

示例9: connect

    def connect(self):
        #self._connected_time = time.time()
        #return HTTPConnection.connect(self)
	#with open("/home/ubuntu/spawn.txt", "a") as tran_file:
    	#    tran_file.write("At Connect = "+str(datetime.now())+"\n")
	self._connected_time = time.time()
        ret = HTTPConnection.connect(self)
        #self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
	#self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
	#self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
        return ret
开发者ID:gayana06,项目名称:Thesis,代码行数:11,代码来源:bufferedhttp.py

示例10: getresponse

 def getresponse(self):
     response = HTTPConnection.getresponse(self)
     LOG.debug(
         "HTTP PERF: %(time).5f seconds to %(method)s " "%(host)s:%(port)s %(path)s)",
         {
             "time": time.time() - self._connected_time,
             "method": self._method,
             "host": self.host,
             "port": self.port,
             "path": self._path,
         },
     )
     return response
开发者ID:leochenliu,项目名称:keystone,代码行数:13,代码来源:bufferedhttp.py

示例11: putrequest

    def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0):
        '''Send a request to the server.

        :param method: specifies an HTTP request method, e.g. 'GET'.
        :param url: specifies the object being requested, e.g. '/index.html'.
        :param skip_host: if True does not add automatically a 'Host:' header
        :param skip_accept_encoding: if True does not add automatically an
           'Accept-Encoding:' header
        '''
        self._method = method
        self._path = url
        return HTTPConnection.putrequest(self, method, url, skip_host,
                                         skip_accept_encoding)
开发者ID:openstack,项目名称:swift,代码行数:13,代码来源:bufferedhttp.py

示例12: http_connection

def http_connection(url, proxy=None):
    """
    Make an HTTPConnection or HTTPSConnection

    :param url: url to connect to
    :param proxy: proxy to connect through, if any; None by default; str of the
                  format 'http://127.0.0.1:8888' to set one
    :returns: tuple of (parsed url, connection object)
    :raises ClientException: Unable to handle protocol scheme
    """
    parsed = urlparse(url)
    proxy_parsed = urlparse(proxy) if proxy else None
    if parsed.scheme == 'http':
        conn = HTTPConnection((proxy_parsed if proxy else parsed).netloc)
    elif parsed.scheme == 'https':
        conn = HTTPSConnection((proxy_parsed if proxy else parsed).netloc)
    else:
        raise ClientException('Cannot handle protocol scheme %s for url %s' %
                              (parsed.scheme, repr(url)))
    if proxy:
        conn._set_tunnel(parsed.hostname, parsed.port)
    return parsed, conn
开发者ID:sohonet,项目名称:ssbench,代码行数:22,代码来源:swift_client.py

示例13: getresponse

 def getresponse(self):
     response = HTTPConnection.getresponse(self)
     
     return response
开发者ID:code-hunter,项目名称:mstore,代码行数:4,代码来源:bufferedhttp.py

示例14: putrequest

 def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0):
     self._method = method
     self._path = url
     return HTTPConnection.putrequest(self, method, url, skip_host,
                                      skip_accept_encoding)
开发者ID:AsherBond,项目名称:colony,代码行数:5,代码来源:bufferedhttp.py

示例15: connect

 def connect(self):
     self._connected_time = time.time()
     return HTTPConnection.connect(self)
开发者ID:AsherBond,项目名称:colony,代码行数:3,代码来源:bufferedhttp.py


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