urllib3 ProxyManager: thumela imininingwane yokufinyelela ye-Basic ku-proxy_headers
Nikela ngemininingwane yokufinyelela ye-Basic yeproxy nge-ProxyManager.proxy_headers ukuze itholakale ngesikhathi se-HTTPS CONNECT ngaphandle kokuba yizihloko zendawo ekuyiwa kuyo.
I-ProxyManager inengxabano ehlukile ye-proxy_headers yezihloko ezithunyelwa kumxhumanisi. Kwi-proxy eyamukela i-Basic authentication:
import urllib3
proxy_headers = urllib3.make_headers(
proxy_basic_auth=f'{proxy_user}:{proxy_password}'
)
with urllib3.ProxyManager(
'http://proxy.example:8080',
proxy_headers=proxy_headers,
timeout=urllib3.Timeout(connect=5, read=10),
) as http:
response = http.request('GET', 'https://service.example/data')
print(response.status)
Endaweni ejwayelekile ye-HTTP, lezi zihloko zihamba nesicelo esidlulisiwe ziya ku-proxy. Endaweni ye-HTTPS esebenzisa i-CONNECT, zingezokuhlelwa kwethuneli hhayi isicelo ngasinye sewebhusayithi esifihliwe.
Ingxabano ejwayelekile ye-headers ichaza izihloko zesicelo sendawo ekuyiwa kuyo. Le proxy authentication ingeyomunye umamukeli. Ukubeka i-akhawunti ye-proxy lapho akulingani nokuhlela ukushintshana kwe-CONNECT kwangaphambili.
I-make_headers yakha inani lesihloko se-Basic. Ayixoxisani nge-NTLM, ayikhethi isikimu esisekelwayo ngokuzenzakalela, futhi ayifakazeli ukuthi i-proxy iyamukela leyo akhawunti.
I-proxy ene-TLS listener yengeza i-proxy TLS context ehlukile. I-endpoint ye-http:// engenhla ichaza ngamabomu i-HTTP listener ejwayelekile ethwala indawo ye-HTTPS ngethuneli.