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


Python client.HTTPMessage方法代码示例

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


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

示例1: parse_headers

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import HTTPMessage [as 别名]
def parse_headers(fp, _class=HTTPMessage):
  headers = []
  while True:
    line = await fp.readline()
    headers.append(line)
    if line in (b'\r\n', b'\n', b''):
      break
  hstring = b''.join(headers).decode('iso-8859-1')
  return email.parser.Parser(_class=_class).parsestr(hstring) 
开发者ID:johnnykv,项目名称:heralding,代码行数:11,代码来源:aioclient.py

示例2: _create_mock_request

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import HTTPMessage [as 别名]
def _create_mock_request(self, path='http://www.example.com/test/path/'):
        mock_request = Mock()
        mock_request.path = path
        mock_request.command = 'GET'
        headers = HTTPMessage()
        headers.add_header('Host', 'www.example.com')
        headers.add_header('Accept', '*/*')
        mock_request.headers = headers
        return mock_request 
开发者ID:wkeeling,项目名称:selenium-wire,代码行数:11,代码来源:test_storage.py

示例3: _create_mock_resonse

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import HTTPMessage [as 别名]
def _create_mock_resonse(self):
        mock_response = Mock()
        mock_response.status = 200
        mock_response.reason = 'OK'
        headers = HTTPMessage()
        headers.add_header('Content-Type', 'application/json')
        headers.add_header('Content-Length', '500')
        mock_response.headers = headers
        return mock_response 
开发者ID:wkeeling,项目名称:selenium-wire,代码行数:11,代码来源:test_storage.py

示例4: _make_response

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import HTTPMessage [as 别名]
def _make_response(self, result, url):

        data = "\r\n".join(["%s: %s" % (k, v) for k, v in result.header_items])

        if PY2:
            headers = HTTPMessage(BytesIO(data))
        else:
            import email
            headers = email.message_from_string(data)

        response = addinfourl(BytesIO(result.data), headers, url)
        code, msg = result.status.split(None, 1)
        response.code, response.msg = int(code), msg
        return response 
开发者ID:Naayouu,项目名称:Hatkey,代码行数:16,代码来源:browser.py

示例5: __init__

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import HTTPMessage [as 别名]
def __init__(self, status):
        super(MockHttpResponse, self).__init__()
        self.status = status
        self.strict = 0
        self.version = 0
        self.reason = None
        self.msg = HTTPMessage(io.BytesIO())
        self.closed = True 
开发者ID:SFDO-Tooling,项目名称:CumulusCI,代码行数:10,代码来源:conftest.py

示例6: _parse_headers

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import HTTPMessage [as 别名]
def _parse_headers(fp):
        """This is a modification of the python3 http.clint.parse_headers function."""
        headers = []
        while True:
            line = fp.readline(65536)
            headers.append(line)
            if line in (b'\r\n', b'\n', b''):
                break
        hstring = b''.join(headers)
        return email.parser.Parser(_class=HTTPMessage).parsestr(hstring.decode('iso-8859-1')), hstring 
开发者ID:recrm,项目名称:ArchiveTools,代码行数:12,代码来源:warc-extractor.py


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