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


Python client.parse_headers方法代码示例

本文整理汇总了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 
开发者ID:leancloud,项目名称:satori,代码行数:9,代码来源:pywsgi.py

示例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) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:15,代码来源:test_httplib.py

示例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 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:7,代码来源:test_httplib.py

示例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 
开发者ID:aliyun,项目名称:aliyun-log-python-sdk,代码行数:29,代码来源:logclient.py

示例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) 
开发者ID:ShikyoKira,项目名称:Project-New-Reign---Nemesis-Main,代码行数:15,代码来源:test_httplib.py


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