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