(self, req, proxy, type)
| 775 | meth(r, proxy, type)) |
| 776 | |
| 777 | def proxy_open(self, req, proxy, type): |
| 778 | orig_type = req.type |
| 779 | proxy_type, user, password, hostport = _parse_proxy(proxy) |
| 780 | if proxy_type is None: |
| 781 | proxy_type = orig_type |
| 782 | |
| 783 | if req.host and proxy_bypass(req.host): |
| 784 | return None |
| 785 | |
| 786 | if user and password: |
| 787 | user_pass = '%s:%s' % (unquote(user), |
| 788 | unquote(password)) |
| 789 | creds = base64.b64encode(user_pass.encode()).decode("ascii") |
| 790 | req.add_header('Proxy-authorization', 'Basic ' + creds) |
| 791 | hostport = unquote(hostport) |
| 792 | req.set_proxy(hostport, proxy_type) |
| 793 | if orig_type == proxy_type or orig_type == 'https': |
| 794 | # let other handlers take care of it |
| 795 | return None |
| 796 | else: |
| 797 | # need to start over, because the other handlers don't |
| 798 | # grok the proxy's URL type |
| 799 | # e.g. if we have a constructor arg proxies like so: |
| 800 | # {'http': 'ftp://proxy.example.com'}, we may end up turning |
| 801 | # a request for http://acme.example.com/a into one for |
| 802 | # ftp://proxy.example.com/a |
| 803 | return self.parent.open(req, timeout=req.timeout) |
| 804 | |
| 805 | class HTTPPasswordMgr: |
| 806 |
nothing calls this directly
no test coverage detected