Python urllib.request.header_items() Examples
The following are 5
code examples of urllib.request.header_items().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
urllib.request
, or try the search function
.
Example #1
Source File: test_urllib2net.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_custom_headers(self): url = "http://www.example.com" with support.transient_internet(url): opener = urllib.request.build_opener() request = urllib.request.Request(url) self.assertFalse(request.header_items()) opener.open(request) self.assertTrue(request.header_items()) self.assertTrue(request.has_header('User-agent')) request.add_header('User-Agent','Test-Agent') opener.open(request) self.assertEqual(request.get_header('User-agent'),'Test-Agent')
Example #2
Source File: test_urllib2net.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_custom_headers(self): url = "http://www.example.com" with support.transient_internet(url): opener = urllib.request.build_opener() request = urllib.request.Request(url) self.assertFalse(request.header_items()) opener.open(request) self.assertTrue(request.header_items()) self.assertTrue(request.has_header('User-agent')) request.add_header('User-Agent','Test-Agent') opener.open(request) self.assertEqual(request.get_header('User-agent'),'Test-Agent')
Example #3
Source File: test_urllib2net.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_custom_headers(self): url = "http://www.example.com" with support.transient_internet(url): opener = urllib.request.build_opener() request = urllib.request.Request(url) self.assertFalse(request.header_items()) opener.open(request) self.assertTrue(request.header_items()) self.assertTrue(request.has_header('User-agent')) request.add_header('User-Agent','Test-Agent') opener.open(request) self.assertEqual(request.get_header('User-agent'),'Test-Agent')
Example #4
Source File: utils_log.py From motu-client-python with GNU Lesser General Public License v3.0 | 5 votes |
def http_request(self, request): host, full_url = request.host, request.get_full_url() url_path = full_url[full_url.find(host) + len(host):] log_url ( self.log, "Requesting: ", request.get_full_url(), TRACE_LEVEL ) self.log.log(self.log_level, "%s %s" % (request.get_method(), url_path)) for header in request.header_items(): self.log.log(self.log_level, " . %s: %s" % header[:]) return request
Example #5
Source File: test_urllib2net.py From android_universal with MIT License | 5 votes |
def test_custom_headers(self): url = support.TEST_HTTP_URL with support.transient_internet(url): opener = urllib.request.build_opener() request = urllib.request.Request(url) self.assertFalse(request.header_items()) opener.open(request) self.assertTrue(request.header_items()) self.assertTrue(request.has_header('User-agent')) request.add_header('User-Agent','Test-Agent') opener.open(request) self.assertEqual(request.get_header('User-agent'),'Test-Agent')