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


Python Request.get_header方法代码示例

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


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

示例1: get_cookie

# 需要导入模块: from urllib2 import Request [as 别名]
# 或者: from urllib2.Request import get_header [as 别名]
 def get_cookie(self, path):
     request = Request(path)
     if len(self._cookies) == 0:
         self.load()
     self.add_cookie_header(request)
     if request.get_header('Cookie'):
         return "Cookie: %s\r\n" % request.get_header('Cookie')
     return None
开发者ID:GSI,项目名称:pigshell,代码行数:10,代码来源:psty.py

示例2: test_proxy_https_proxy_authorization

# 需要导入模块: from urllib2 import Request [as 别名]
# 或者: from urllib2.Request import get_header [as 别名]
 def test_proxy_https_proxy_authorization(self):
     o = OpenerDirector()
     ph = urllib2.ProxyHandler(dict(https="proxy.example.com:3128"))
     o.add_handler(ph)
     https_handler = MockHTTPSHandler()
     o.add_handler(https_handler)
     req = Request("https://www.example.com/")
     req.add_header("Proxy-Authorization", "FooBar")
     req.add_header("User-Agent", "Grail")
     self.assertEqual(req.get_host(), "www.example.com")
     self.assertIsNone(req._tunnel_host)
     r = o.open(req)
     # Verify Proxy-Authorization gets tunneled to request.
     # httpsconn req_headers do not have the Proxy-Authorization header but
     # the req will have.
     self.assertNotIn(("Proxy-Authorization", "FooBar"), https_handler.httpconn.req_headers)
     self.assertIn(("User-Agent", "Grail"), https_handler.httpconn.req_headers)
     self.assertIsNotNone(req._tunnel_host)
     self.assertEqual(req.get_host(), "proxy.example.com:3128")
     self.assertEqual(req.get_header("Proxy-authorization"), "FooBar")
开发者ID:int3,项目名称:jython,代码行数:22,代码来源:test_urllib2.py

示例3: get_header

# 需要导入模块: from urllib2 import Request [as 别名]
# 或者: from urllib2.Request import get_header [as 别名]
 def get_header(self, name, default = None):
     if not isinstance(self.headers, HeaderDictionary):
         return _Request.get_header(self, name, default)
     return self.headers.get_header_value(name, default)
开发者ID:mcruse,项目名称:monotone,代码行数:6,代码来源:request.py


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