當前位置: 首頁>>代碼示例>>Python>>正文


Python cookielib.DEFAULT_HTTP_PORT屬性代碼示例

本文整理匯總了Python中cookielib.DEFAULT_HTTP_PORT屬性的典型用法代碼示例。如果您正苦於以下問題:Python cookielib.DEFAULT_HTTP_PORT屬性的具體用法?Python cookielib.DEFAULT_HTTP_PORT怎麽用?Python cookielib.DEFAULT_HTTP_PORT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在cookielib的用法示例。


在下文中一共展示了cookielib.DEFAULT_HTTP_PORT屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_request_port

# 需要導入模塊: import cookielib [as 別名]
# 或者: from cookielib import DEFAULT_HTTP_PORT [as 別名]
def test_request_port(self):
        from urllib2 import Request
        from cookielib import request_port, DEFAULT_HTTP_PORT
        req = Request("http://www.acme.com:1234/",
                      headers={"Host": "www.acme.com:4321"})
        self.assertEqual(request_port(req), "1234")
        req = Request("http://www.acme.com/",
                      headers={"Host": "www.acme.com:4321"})
        self.assertEqual(request_port(req), DEFAULT_HTTP_PORT) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:11,代碼來源:test_cookielib.py

示例2: test_ns_parser

# 需要導入模塊: import cookielib [as 別名]
# 或者: from cookielib import DEFAULT_HTTP_PORT [as 別名]
def test_ns_parser(self):
        from cookielib import CookieJar, DEFAULT_HTTP_PORT

        c = CookieJar()
        interact_netscape(c, "http://www.acme.com/",
                          'spam=eggs; DoMain=.acme.com; port; blArgh="feep"')
        interact_netscape(c, "http://www.acme.com/", 'ni=ni; port=80,8080')
        interact_netscape(c, "http://www.acme.com:80/", 'nini=ni')
        interact_netscape(c, "http://www.acme.com:80/", 'foo=bar; expires=')
        interact_netscape(c, "http://www.acme.com:80/", 'spam=eggs; '
                          'expires="Foo Bar 25 33:22:11 3022"')

        cookie = c._cookies[".acme.com"]["/"]["spam"]
        self.assertEqual(cookie.domain, ".acme.com")
        self.assertTrue(cookie.domain_specified)
        self.assertEqual(cookie.port, DEFAULT_HTTP_PORT)
        self.assertTrue(not cookie.port_specified)
        # case is preserved
        self.assertTrue(cookie.has_nonstandard_attr("blArgh") and
                     not cookie.has_nonstandard_attr("blargh"))

        cookie = c._cookies["www.acme.com"]["/"]["ni"]
        self.assertEqual(cookie.domain, "www.acme.com")
        self.assertTrue(not cookie.domain_specified)
        self.assertEqual(cookie.port, "80,8080")
        self.assertTrue(cookie.port_specified)

        cookie = c._cookies["www.acme.com"]["/"]["nini"]
        self.assertTrue(cookie.port is None)
        self.assertTrue(not cookie.port_specified)

        # invalid expires should not cause cookie to be dropped
        foo = c._cookies["www.acme.com"]["/"]["foo"]
        spam = c._cookies["www.acme.com"]["/"]["foo"]
        self.assertTrue(foo.expires is None)
        self.assertTrue(spam.expires is None) 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:38,代碼來源:test_cookielib.py

示例3: test_ns_parser

# 需要導入模塊: import cookielib [as 別名]
# 或者: from cookielib import DEFAULT_HTTP_PORT [as 別名]
def test_ns_parser(self):
        from cookielib import CookieJar, DEFAULT_HTTP_PORT

        c = CookieJar()
        interact_netscape(c, "http://www.acme.com/",
                          'spam=eggs; DoMain=.acme.com; port; blArgh="feep"')
        interact_netscape(c, "http://www.acme.com/", 'ni=ni; port=80,8080')
        interact_netscape(c, "http://www.acme.com:80/", 'nini=ni')
        interact_netscape(c, "http://www.acme.com:80/", 'foo=bar; expires=')
        interact_netscape(c, "http://www.acme.com:80/", 'spam=eggs; '
                          'expires="Foo Bar 25 33:22:11 3022"')

        cookie = c._cookies[".acme.com"]["/"]["spam"]
        self.assertEqual(cookie.domain, ".acme.com")
        self.assertTrue(cookie.domain_specified)
        self.assertEqual(cookie.port, DEFAULT_HTTP_PORT)
        self.assertFalse(cookie.port_specified)
        # case is preserved
        self.assertTrue(cookie.has_nonstandard_attr("blArgh"))
        self.assertFalse(cookie.has_nonstandard_attr("blargh"))

        cookie = c._cookies["www.acme.com"]["/"]["ni"]
        self.assertEqual(cookie.domain, "www.acme.com")
        self.assertFalse(cookie.domain_specified)
        self.assertEqual(cookie.port, "80,8080")
        self.assertTrue(cookie.port_specified)

        cookie = c._cookies["www.acme.com"]["/"]["nini"]
        self.assertIsNone(cookie.port)
        self.assertFalse(cookie.port_specified)

        # invalid expires should not cause cookie to be dropped
        foo = c._cookies["www.acme.com"]["/"]["foo"]
        spam = c._cookies["www.acme.com"]["/"]["foo"]
        self.assertIsNone(foo.expires)
        self.assertIsNone(spam.expires) 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:38,代碼來源:test_cookielib.py

示例4: test_ns_parser

# 需要導入模塊: import cookielib [as 別名]
# 或者: from cookielib import DEFAULT_HTTP_PORT [as 別名]
def test_ns_parser(self):
        from cookielib import CookieJar, DEFAULT_HTTP_PORT

        c = CookieJar()
        interact_netscape(c, "http://www.acme.com/",
                          'spam=eggs; DoMain=.acme.com; port; blArgh="feep"')
        interact_netscape(c, "http://www.acme.com/", 'ni=ni; port=80,8080')
        interact_netscape(c, "http://www.acme.com:80/", 'nini=ni')
        interact_netscape(c, "http://www.acme.com:80/", 'foo=bar; expires=')
        interact_netscape(c, "http://www.acme.com:80/", 'spam=eggs; '
                          'expires="Foo Bar 25 33:22:11 3022"')

        cookie = c._cookies[".acme.com"]["/"]["spam"]
        self.assertEquals(cookie.domain, ".acme.com")
        self.assert_(cookie.domain_specified)
        self.assertEquals(cookie.port, DEFAULT_HTTP_PORT)
        self.assert_(not cookie.port_specified)
        # case is preserved
        self.assert_(cookie.has_nonstandard_attr("blArgh") and
                     not cookie.has_nonstandard_attr("blargh"))

        cookie = c._cookies["www.acme.com"]["/"]["ni"]
        self.assertEquals(cookie.domain, "www.acme.com")
        self.assert_(not cookie.domain_specified)
        self.assertEquals(cookie.port, "80,8080")
        self.assert_(cookie.port_specified)

        cookie = c._cookies["www.acme.com"]["/"]["nini"]
        self.assert_(cookie.port is None)
        self.assert_(not cookie.port_specified)

        # invalid expires should not cause cookie to be dropped
        foo = c._cookies["www.acme.com"]["/"]["foo"]
        spam = c._cookies["www.acme.com"]["/"]["foo"]
        self.assert_(foo.expires is None)
        self.assert_(spam.expires is None) 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:38,代碼來源:test_cookielib.py

示例5: test_request_port

# 需要導入模塊: import cookielib [as 別名]
# 或者: from cookielib import DEFAULT_HTTP_PORT [as 別名]
def test_request_port(self):
        from urllib2 import Request
        from cookielib import request_port, DEFAULT_HTTP_PORT
        req = Request("http://www.acme.com:1234/",
                      headers={"Host": "www.acme.com:4321"})
        self.assertEquals(request_port(req), "1234")
        req = Request("http://www.acme.com/",
                      headers={"Host": "www.acme.com:4321"})
        self.assertEquals(request_port(req), DEFAULT_HTTP_PORT) 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:11,代碼來源:test_cookielib.py

示例6: test_ns_parser

# 需要導入模塊: import cookielib [as 別名]
# 或者: from cookielib import DEFAULT_HTTP_PORT [as 別名]
def test_ns_parser(self):
        from cookielib import CookieJar, DEFAULT_HTTP_PORT

        c = CookieJar()
        interact_netscape(c, "http://www.acme.com/",
                          'spam=eggs; DoMain=.acme.com; port; blArgh="feep"')
        interact_netscape(c, "http://www.acme.com/", 'ni=ni; port=80,8080')
        interact_netscape(c, "http://www.acme.com:80/", 'nini=ni')
        interact_netscape(c, "http://www.acme.com:80/", 'foo=bar; expires=')
        interact_netscape(c, "http://www.acme.com:80/", 'spam=eggs; '
                          'expires="Foo Bar 25 33:22:11 3022"')
        interact_netscape(c, 'http://www.acme.com/', 'fortytwo=')
        interact_netscape(c, 'http://www.acme.com/', '=unladenswallow')
        interact_netscape(c, 'http://www.acme.com/', 'holyhandgrenade')

        cookie = c._cookies[".acme.com"]["/"]["spam"]
        self.assertEqual(cookie.domain, ".acme.com")
        self.assertTrue(cookie.domain_specified)
        self.assertEqual(cookie.port, DEFAULT_HTTP_PORT)
        self.assertFalse(cookie.port_specified)
        # case is preserved
        self.assertTrue(cookie.has_nonstandard_attr("blArgh"))
        self.assertFalse(cookie.has_nonstandard_attr("blargh"))

        cookie = c._cookies["www.acme.com"]["/"]["ni"]
        self.assertEqual(cookie.domain, "www.acme.com")
        self.assertFalse(cookie.domain_specified)
        self.assertEqual(cookie.port, "80,8080")
        self.assertTrue(cookie.port_specified)

        cookie = c._cookies["www.acme.com"]["/"]["nini"]
        self.assertIsNone(cookie.port)
        self.assertFalse(cookie.port_specified)

        # invalid expires should not cause cookie to be dropped
        foo = c._cookies["www.acme.com"]["/"]["foo"]
        spam = c._cookies["www.acme.com"]["/"]["foo"]
        self.assertIsNone(foo.expires)
        self.assertIsNone(spam.expires)

        cookie = c._cookies['www.acme.com']['/']['fortytwo']
        self.assertIsNotNone(cookie.value)
        self.assertEqual(cookie.value, '')

        # there should be a distinction between a present but empty value
        # (above) and a value that's entirely missing (below)

        cookie = c._cookies['www.acme.com']['/']['holyhandgrenade']
        self.assertIsNone(cookie.value) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:51,代碼來源:test_cookielib.py


注:本文中的cookielib.DEFAULT_HTTP_PORT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。