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


Python httplib.ResponseNotReady方法代码示例

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


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

示例1: HTTPResponse__getheaders

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import ResponseNotReady [as 别名]
def HTTPResponse__getheaders(self):
    """Return list of (header, value) tuples."""
    if self.msg is None:
        raise httplib.ResponseNotReady()
    return self.msg.items() 
开发者ID:remg427,项目名称:misp42splunk,代码行数:7,代码来源:__init__.py

示例2: do_open

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import ResponseNotReady [as 别名]
def do_open(self, http_class, req):
        h = None
        host = req.get_host()
        if not host:
            raise urllib2.URLError('no host given')

        try:
            need_new_connection = 1
            key = self._get_connection_key(host)
            h = self._connections.get(key)
            if not h is None:
                try:
                    self._start_connection(h, req)
                except:
                    r = None
                else:
                    try: r = h.getresponse()
                    except httplib.ResponseNotReady, e: r = None
                    except httplib.BadStatusLine, e: r = None

                if r is None or r.version == 9:
                    # httplib falls back to assuming HTTP 0.9 if it gets a
                    # bad header back.  This is most likely to happen if
                    # the socket has been closed by the server since we
                    # last used the connection.
                    if DEBUG: print "failed to re-use connection to %s" % host
                    h.close()
                else:
                    if DEBUG: print "re-using connection to %s" % host
                    need_new_connection = 0 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:32,代码来源:keepalive.py

示例3: extractMSIInfo

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import ResponseNotReady [as 别名]
def extractMSIInfo(self, path, wbs):
        import robj

        self.fileType = 'msi'
        self.path = path

        # This is here for backwards compatibility.
        if not wbs.startswith('http'):
            wbs = 'http://%s/api' % wbs

        api = robj.connect(wbs)
        api.msis.append(dict(
            path=os.path.split(path)[1],
            size=os.stat(path).st_size,
        ))
        self.resource = api.msis[-1]

        # put the actual file contents
        self.resource.path = open(path)
        self.resource.refresh()

        self.productName = self.resource.name.encode('utf-8')
        name = self.productName.split()
        if len(name) > 1 and '.' in name[-1]:
            name = '-'.join(name[:-1])
        else:
            name = '-'.join(name)
        self.name = name
        self.version = self.resource.version.encode('utf-8')
        self.platform = self.resource.platform.encode('utf-8')
        self.productCode = self.resource.productCode.encode('utf-8')
        self.upgradeCode = self.resource.upgradeCode.encode('utf-8')

        self.components = [ (x.uuid.encode('utf-8'), x.path.encode('utf-8'))
            for x in self.resource.components ]

        # clean up
        try:
            self.resource.delete()
        except httplib.ResponseNotReady:
            pass 
开发者ID:sassoftware,项目名称:conary,代码行数:43,代码来源:source.py

示例4: _prefetch_in_background

# 需要导入模块: import httplib [as 别名]
# 或者: from httplib import ResponseNotReady [as 别名]
def _prefetch_in_background(self, n, amount, offset):
            headers = {
                'Range': "bytes=" + str(max(offset, 0)) + "-" + str(
                    min((offset + amount) - 1, self.length)  # noqa
                ),
            }

            self._wait_on_prefetch_connection(n)
            while not self.pconn_terminated[n]:
                try:
                    self.pconn[n].request(
                        "GET", self.parsed_url.path, headers=headers)
                    break
                except CannotSendRequest:
                    sleep(1)
            while not self.pconn_terminated[n]:
                try:
                    res = self.pconn[n].getresponse()
                    break
                except ResponseNotReady:
                    # Since we are sharing the connection wait for this to be
                    # ready
                    sleep(1)
            if self.pconn_terminated[n]:
                self._unwait_on_prefetch_connection(n)
                return
            else:
                self._unwait_on_prefetch_connection(n)

            if not(res.status >= 200 and res.status <= 299):
                # Check for a valid status from the server
                return
            data = bytearray(res.length)
            i = 0
            for piece in iter(lambda: res.read(1024), bytes('')):
                if not getattr(threading.currentThread(), "do_run", True):
                    break
                data[i:i + len(piece)] = piece
                i = i + len(piece)
            else:
                return bytes(data)

            # Leaving the thread early, without
            # reading all of the data this will
            # make the connection unusable, refresh it
            self._prepare_prefetch_connection(n) 
开发者ID:plasticityai,项目名称:magnitude,代码行数:48,代码来源:__init__.py


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