当前位置: 首页>>代码示例>>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;未经允许,请勿转载。