當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。