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


Python HTTPResponse.__init__方法代码示例

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


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

示例1: __init__

# 需要导入模块: from httplib import HTTPResponse [as 别名]
# 或者: from httplib.HTTPResponse import __init__ [as 别名]
  def __init__(self, response_str):
    source = FakeSocket(response_str)
    HTTPResponse.__init__(self, source)
    self.begin()



# Request
# error_code 
# command    GET/POST
# path       PATH
# request_version "HTTP/1.0"
# headers   "Headers"
# headers.keys() 
# headers['host']

# Response
# status    CODE
# getheader('Content-Length')
# read(len(response_str)) 
开发者ID:zeulb,项目名称:Webproxy,代码行数:22,代码来源:helper.py

示例2: __init__

# 需要导入模块: from httplib import HTTPResponse [as 别名]
# 或者: from httplib.HTTPResponse import __init__ [as 别名]
    def __init__(self, data):
        """Initialize a new object.

        :param data: a stream of data which contain a discovery response in the HTTP format.
        :type data: str or list[bytes] or list[int]
        :rtype: DiscoveryResponse
        """

        # create a fake socket which is needed by the base class to initialize.
        # initialize the base class
        HTTPResponse.__init__(self, DiscoveryResponse._FakeSocket(data), 1)

        # turn off any debugging in the base class
        self.debuglevel = 0

        # let the base class parse the input
        self.begin()

        # set dedicated properties from the discovery response headers
        self.__location = self.getheader("location")
        self.__usn = self.getheader("usn")
        self.__service = self.getheader("st")

        # parse the location URL
        urlParts = urlparse(self.location)

        self.__locationProtocol = urlParts.scheme.lower()

        self.__locationPath = urlParts.path
        self.__locationHost = urlParts.hostname

        # set the right port depending on if a port was given or the given protocol
        if urlParts.port:
            self.__locationPort = urlParts.port
        else:
            if self.__locationProtocol == "https":
                self.__locationPort = 443
            else:
                self.__locationPort = 80
开发者ID:LarsMichelsen,项目名称:pmatic,代码行数:41,代码来源:discover.py


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