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


Python httplib.HTTPResponse类代码示例

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


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

示例1: read

    def read(self, amt=None):
        if not self._readline_buffer:
            return HTTPResponse.read(self, amt)

        if amt is None:
            # Unbounded read: send anything we have buffered plus whatever
            # is left.
            buffered = self._readline_buffer
            self._readline_buffer = ''
            return buffered + HTTPResponse.read(self, amt)
        elif amt <= len(self._readline_buffer):
            # Bounded read that we can satisfy entirely from our buffer
            res = self._readline_buffer[:amt]
            self._readline_buffer = self._readline_buffer[amt:]
            return res
        else:
            # Bounded read that wants more bytes than we have
            smaller_amt = amt - len(self._readline_buffer)
            buf = self._readline_buffer
            self._readline_buffer = ''
            return buf + HTTPResponse.read(self, smaller_amt)
开发者ID:Ahiknsr,项目名称:swift,代码行数:21,代码来源:bufferedhttp.py

示例2: readline

    def readline(self, size=1024):
        # You'd think Python's httplib would provide this, but it doesn't.
        # It does, however, provide a comment in the HTTPResponse class:
        #
        #  # XXX It would be nice to have readline and __iter__ for this,
        #  # too.
        #
        # Yes, it certainly would.
        while ('\n' not in self._readline_buffer
               and len(self._readline_buffer) < size):
            read_size = size - len(self._readline_buffer)
            chunk = HTTPResponse.read(self, read_size)
            if not chunk:
                break
            self._readline_buffer += chunk

        line, newline, rest = self._readline_buffer.partition('\n')
        self._readline_buffer = rest
        return line + newline
开发者ID:Ahiknsr,项目名称:swift,代码行数:19,代码来源:bufferedhttp.py

示例3: close

 def close(self):
     HTTPResponse.close(self)
     self.sock = None
开发者ID:CiscoAS,项目名称:swift,代码行数:3,代码来源:bufferedhttp.py

示例4: close

 def close(self):
     HTTPResponse.close(self)
     self.sock = None
     self._actual_socket = None
开发者ID:carriercomm,项目名称:oio-sds,代码行数:4,代码来源:http.py

示例5: read

 def read(self, amount=None):
     return HTTPResponse.read(self, amount)
开发者ID:carriercomm,项目名称:oio-sds,代码行数:2,代码来源:http.py


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