MCPcopy Index your code
hub / github.com/python/cpython / open

Method open

Lib/urllib/request.py:470–497  ·  view source on GitHub ↗
(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT)

Source from the content-addressed store, hash-verified

468 return result
469
470 def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
471 # accept a URL or a Request object
472 if isinstance(fullurl, str):
473 req = Request(fullurl, data)
474 else:
475 req = fullurl
476 if data is not None:
477 req.data = data
478
479 req.timeout = timeout
480 protocol = req.type
481
482 # pre-process request
483 meth_name = protocol+"_request"
484 for processor in self.process_request.get(protocol, []):
485 meth = getattr(processor, meth_name)
486 req = meth(req)
487
488 sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method())
489 response = self._open(req, data)
490
491 # post-process response
492 meth_name = protocol+"_response"
493 for processor in self.process_response.get(protocol, []):
494 meth = getattr(processor, meth_name)
495 response = meth(req, response)
496
497 return response
498
499 def _open(self, req, data=None):
500 result = self._call_chain(self.handle_open, 'default',

Calls 5

get_methodMethod · 0.95
_openMethod · 0.95
RequestClass · 0.85
methFunction · 0.85
getMethod · 0.45

Tested by 15

test_handledMethod · 0.76
test_handler_orderMethod · 0.76
test_http_errorMethod · 0.76
test_processorsMethod · 0.76
test_proxyMethod · 0.76
test_proxy_no_proxyMethod · 0.76
test_proxy_httpsMethod · 0.76