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


Python cookielib.parse_ns_headers方法代码示例

本文整理汇总了Python中cookielib.parse_ns_headers方法的典型用法代码示例。如果您正苦于以下问题:Python cookielib.parse_ns_headers方法的具体用法?Python cookielib.parse_ns_headers怎么用?Python cookielib.parse_ns_headers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cookielib的用法示例。


在下文中一共展示了cookielib.parse_ns_headers方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_parse_ns_headers

# 需要导入模块: import cookielib [as 别名]
# 或者: from cookielib import parse_ns_headers [as 别名]
def test_parse_ns_headers(self):
        from cookielib import parse_ns_headers

        # missing domain value (invalid cookie)
        self.assertEqual(
            parse_ns_headers(["foo=bar; path=/; domain"]),
            [[("foo", "bar"),
              ("path", "/"), ("domain", None), ("version", "0")]]
            )
        # invalid expires value
        self.assertEqual(
            parse_ns_headers(["foo=bar; expires=Foo Bar 12 33:22:11 2000"]),
            [[("foo", "bar"), ("expires", None), ("version", "0")]]
            )
        # missing cookie value (valid cookie)
        self.assertEqual(
            parse_ns_headers(["foo"]),
            [[("foo", None), ("version", "0")]]
            )
        # shouldn't add version if header is empty
        self.assertEqual(parse_ns_headers([""]), []) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:23,代码来源:test_cookielib.py

示例2: test_parse_ns_headers

# 需要导入模块: import cookielib [as 别名]
# 或者: from cookielib import parse_ns_headers [as 别名]
def test_parse_ns_headers(self):
        from cookielib import parse_ns_headers

        # missing domain value (invalid cookie)
        self.assertEquals(
            parse_ns_headers(["foo=bar; path=/; domain"]),
            [[("foo", "bar"),
              ("path", "/"), ("domain", None), ("version", "0")]]
            )
        # invalid expires value
        self.assertEquals(
            parse_ns_headers(["foo=bar; expires=Foo Bar 12 33:22:11 2000"]),
            [[("foo", "bar"), ("expires", None), ("version", "0")]]
            )
        # missing cookie value (valid cookie)
        self.assertEquals(
            parse_ns_headers(["foo"]),
            [[("foo", None), ("version", "0")]]
            )
        # shouldn't add version if header is empty
        self.assertEquals(parse_ns_headers([""]), []) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:23,代码来源:test_cookielib.py

示例3: test_parse_ns_headers_expires

# 需要导入模块: import cookielib [as 别名]
# 或者: from cookielib import parse_ns_headers [as 别名]
def test_parse_ns_headers_expires(self):
        from cookielib import parse_ns_headers

        # quotes should be stripped
        expected = [[('foo', 'bar'), ('expires', 2209069412L), ('version', '0')]]
        for hdr in [
            'foo=bar; expires=01 Jan 2040 22:23:32 GMT',
            'foo=bar; expires="01 Jan 2040 22:23:32 GMT"',
            ]:
            self.assertEqual(parse_ns_headers([hdr]), expected) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_cookielib.py

示例4: test_parse_ns_headers_version

# 需要导入模块: import cookielib [as 别名]
# 或者: from cookielib import parse_ns_headers [as 别名]
def test_parse_ns_headers_version(self):
        from cookielib import parse_ns_headers

        # quotes should be stripped
        expected = [[('foo', 'bar'), ('version', '1')]]
        for hdr in [
            'foo=bar; version="1"',
            'foo=bar; Version="1"',
            ]:
            self.assertEqual(parse_ns_headers([hdr]), expected) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_cookielib.py

示例5: test_parse_ns_headers_special_names

# 需要导入模块: import cookielib [as 别名]
# 或者: from cookielib import parse_ns_headers [as 别名]
def test_parse_ns_headers_special_names(self):
        # names such as 'expires' are not special in first name=value pair
        # of Set-Cookie: header
        from cookielib import parse_ns_headers

        # Cookie with name 'expires'
        hdr = 'expires=01 Jan 2040 22:23:32 GMT'
        expected = [[("expires", "01 Jan 2040 22:23:32 GMT"), ("version", "0")]]
        self.assertEqual(parse_ns_headers([hdr]), expected) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_cookielib.py

示例6: test_parse_ns_headers

# 需要导入模块: import cookielib [as 别名]
# 或者: from cookielib import parse_ns_headers [as 别名]
def test_parse_ns_headers(self):
        from cookielib import parse_ns_headers

        # missing domain value (invalid cookie)
        self.assertEqual(
            parse_ns_headers(["foo=bar; path=/; domain"]),
            [[("foo", "bar"),
              ("path", "/"), ("domain", None), ("version", "0")]]
            )
        # invalid expires value
        self.assertEqual(
            parse_ns_headers(["foo=bar; expires=Foo Bar 12 33:22:11 2000"]),
            [[("foo", "bar"), ("expires", None), ("version", "0")]]
            )
        # missing cookie value (valid cookie)
        self.assertEqual(
            parse_ns_headers(["foo"]),
            [[("foo", None), ("version", "0")]]
            )
        # missing cookie values for parsed attributes
        self.assertEqual(
            parse_ns_headers(['foo=bar; expires']),
            [[('foo', 'bar'), ('expires', None), ('version', '0')]])
        self.assertEqual(
            parse_ns_headers(['foo=bar; version']),
            [[('foo', 'bar'), ('version', None)]])
        # shouldn't add version if header is empty
        self.assertEqual(parse_ns_headers([""]), []) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:30,代码来源:test_cookielib.py

示例7: test_parse_ns_headers_special_names

# 需要导入模块: import cookielib [as 别名]
# 或者: from cookielib import parse_ns_headers [as 别名]
def test_parse_ns_headers_special_names(self):
        # names such as 'expires' are not special in first name=value pair
        # of Set-Cookie: header
        from cookielib import parse_ns_headers

        # Cookie with name 'expires'
        hdr = 'expires=01 Jan 2040 22:23:32 GMT'
        expected = [[("expires", "01 Jan 2040 22:23:32 GMT"), ("version", "0")]]
        self.assertEquals(parse_ns_headers([hdr]), expected) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:11,代码来源:test_cookielib.py


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