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