本文整理汇总了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)