Pyjo.UserAgent.Proxy - User agent proxy manager¶
from Pyjo.UserAgent.Proxy import Proxy
proxy = Proxy()
proxy.detect()
print(proxy.http)
# Or import the module, as in Google Python Style Guide
import Pyjo.UserAgent.Proxy
proxy = Pyjo.UserAgent.Proxy.new()
proxy.detect()
print(proxy.http)
Pyjo.UserAgent.Proxy manages proxy servers for Pyjo.UserAgent.
See also¶
Pyjoyment, https://mojolicious.org.
Ported from Mojo::UserAgent::Proxy of Mojolicious 9.49.
Classes¶
- class Pyjo.UserAgent.Proxy.Pyjo_UserAgent_Proxy(*, http: str | None = None, https: str | None = None, no: list[str] | None = None)[source]¶
Pyjo.UserAgent.Proxyinherits all methods fromPyjo.Baseand implements the following new ones.- detect() Self[source]¶
proxy = proxy.detect()
Check environment variables
HTTP_PROXY,http_proxy,HTTPS_PROXY,https_proxy,NO_PROXYandno_proxyfor proxy information. Automatic proxy detection can be enabled with thePYJO_PROXYenvironment variable.
- http¶
http = proxy.http proxy.http = 'socks://sri:secret@127.0.0.1:8080'
Proxy server to use for HTTP and WebSocket requests.
- https¶
https = proxy.https proxy.https = 'http://sri:secret@127.0.0.1:8080'
Proxy server to use for HTTPS and WebSocket requests.
- is_needed(domain: str) bool[source]¶
boolean = proxy.is_needed('intranet.example.com')
Check if request for domain would use a proxy server.
- no¶
no = proxy.no proxy.no = ['localhost', 'intranet.mojolicious.org']
Domains that don’t require a proxy server to be used.
- prepare(tx: Pyjo_Transaction) None[source]¶
proxy.prepare(Pyjo.Transaction.HTTP.new())
Prepare proxy server information for transaction.