Mojo::U...::Proxy(3)

πŸ’… Mojo::UserAgent::Proxy(3) β€” the user agent proxy manager, bestie edition

okay so real talk: this is a page from the User Contributed Perl Documentation section of the manual, and the whole thing is literally called Mojo::UserAgent::Proxy (the header up top just abbreviates it to Mojo::U...::Proxy because man pages are dramatic and love a cliffhanger). It's a proxy manager. For a user agent. It manages proxies. Slay.


✨ SYNOPSIS ✨

like, here's the whole vibe in five lines:

use Mojo::UserAgent::Proxy;

my $proxy = Mojo::UserAgent::Proxy->new;
$proxy->detect;
say $proxy->http;

that's it. that's the whole thing. make one, detect stuff, print the http proxy. iconic behaviour honestly.


🌸 DESCRIPTION 🌸

Mojo::UserAgent::Proxy manages proxy servers for Mojo::UserAgent. no cap, that's its entire job and it does it well. it's the little guy behind the scenes making sure your requests go through the right door. 🫢


πŸŽ€ ATTRIBUTES πŸŽ€

Mojo::UserAgent::Proxy implements the following attributes. (yes, "implements". very main character of it.)

πŸ’– http

my $http = $proxy->http;
$proxy   = $proxy->http('socks://sri:secret@127.0.0.1:8080');

the proxy server to use for HTTP and WebSocket requests. that's the one. notice the example uses a socks:// URL β€” yes bestie, socks is on the menu. πŸ’…

πŸ’œ https

my $https = $proxy->https;
$proxy    = $proxy->https('http://sri:secret@127.0.0.1:8080');

the proxy server to use for HTTPS and WebSocket requests. same deal, different scheme. yes, both of them cover WebSocket requests β€” don't @ me, that's what the page says.

πŸ¦‹ not

my $not = $proxy->not;
$proxy  = $proxy->not(['localhost', 'intranet.mojolicious.org']);

domains that don't require a proxy server to be used. they get the VIP skip-the-line treatment. it takes an arrayref, so load it up. ✨


πŸ”₯ METHODS πŸ”₯

Mojo::UserAgent::Proxy inherits all methods from Mojo::Base and implements the following new ones. (free methods from your parent, plus these three baddies.)

πŸ’€ detect

$proxy = $proxy->detect;

checks environment variables HTTP_PROXY, http_proxy, HTTPS_PROXY, https_proxy, NO_PROXY and no_proxy for proxy information. yes β€” both the uppercase and lowercase versions of each, it's thorough like that. 🌈

automatic proxy detection can be enabled with the MOJO_PROXY environment variable. go off, environment variable. πŸ‘‘

⭐ is_needed

my $bool = $proxy->is_needed('intranet.example.com');

checks if a request for a domain would use a proxy server. returns a bool, so you get a tidy little true/false back. vibe check for your domain, basically. 🧚

🌸 prepare

$proxy->prepare(Mojo::Transaction::HTTP->new);

prepares proxy server information for a transaction. you hand it a Mojo::Transaction::HTTP and it does the prep work so the transaction doesn't have to. teamwork makes the dream work. 🫢


πŸ“ SEE ALSO πŸ“

go read those too, iykyk. πŸ’–


lowkey a public service announcement: this is User Contributed Perl Documentation, so it's the community's finest, not core Perl's. treat it with the respect it deserves (all of it).

alright bestie that's the page πŸ’… it's perl v5.42.0, dated 2026-07-15, and this little manual moment was brought to you by the Mojo::U...::Proxy(3) page β€” truncated name and all. mwah. πŸŽ€βœ¨

πŸ“¦ where this page comes from