本文整理匯總了Python中http.client.parse_headers方法的典型用法代碼示例。如果您正苦於以下問題:Python client.parse_headers方法的具體用法?Python client.parse_headers怎麽用?Python client.parse_headers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類http.client
的用法示例。
在下文中一共展示了client.parse_headers方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: headers_factory
# 需要導入模塊: from http import client [as 別名]
# 或者: from http.client import parse_headers [as 別名]
def headers_factory(fp, *args):
try:
ret = client.parse_headers(fp, _class=OldMessage)
except client.LineTooLong:
ret = OldMessage()
ret.status = 'Line too long'
return ret
示例2: test_all
# 需要導入模塊: from http import client [as 別名]
# 或者: from http.client import parse_headers [as 別名]
def test_all(self):
# Documented objects defined in the module should be in __all__
expected = {"responses"} # White-list documented dict() object
# HTTPMessage, parse_headers(), and the HTTP status code constants are
# intentionally omitted for simplicity
blacklist = {"HTTPMessage", "parse_headers"}
for name in dir(client):
if name in blacklist:
continue
module_object = getattr(client, name)
if getattr(module_object, "__module__", None) == "http.client":
expected.add(name)
self.assertCountEqual(client.__all__, expected)
示例3: get_headers_and_fp
# 需要導入模塊: from http import client [as 別名]
# 或者: from http.client import parse_headers [as 別名]
def get_headers_and_fp(self):
f = io.BytesIO(self.sock.data)
f.readline() # read the request line
message = client.parse_headers(f)
return message, f
示例4: _apply_cn_keys_patch
# 需要導入模塊: from http import client [as 別名]
# 或者: from http.client import parse_headers [as 別名]
def _apply_cn_keys_patch():
"""
apply this patch due to an issue in http.client.parse_headers
when there're multi-bytes in headers. it will truncate some headers.
https://github.com/aliyun/aliyun-log-python-sdk/issues/79
"""
import sys
if sys.version_info[:2] == (3, 5):
import http.client as hc
old_parse = hc.parse_headers
def parse_header(*args, **kwargs):
fp = args[0]
old_readline = fp.readline
def new_readline(*args, **kwargs):
ret = old_readline(*args, **kwargs)
if ret.lower().startswith(b'x-log-query-info'):
return b'x-log-query-info: \r\n'
return ret
fp.readline = new_readline
ret = old_parse(*args, **kwargs)
return ret
hc.parse_headers = parse_header
示例5: test_all
# 需要導入模塊: from http import client [as 別名]
# 或者: from http.client import parse_headers [as 別名]
def test_all(self):
# Documented objects defined in the module should be in __all__
expected = {"responses"} # White-list documented dict() object
# HTTPMessage, parse_headers(), and the HTTP status code constants are
# intentionally omitted for simplicity
blacklist = {"HTTPMessage", "parse_headers"}
for name in dir(client):
if name.startswith("_") or name in blacklist:
continue
module_object = getattr(client, name)
if getattr(module_object, "__module__", None) == "http.client":
expected.add(name)
self.assertCountEqual(client.__all__, expected)