App-Pod
view release on metacpan or search on metacpan
t/01-usage-simple.t view on Meta::CPAN
'Events (2):',
' prepare - Emitted whenever a new transaction is be ...',
' start - Emitted whenever a new transaction is ab ...',
'',
'Methods (36):',
' build_tx - Generate Mojo::Transaction::H ...',
' build_websocket_tx - Generate Mojo::Transaction::H ...',
' ca - Path to TLS certificate autho ...',
' cert - Path to TLS certificate file, ...',
' connect_timeout - Maximum amount of time in sec ...',
' cookie_jar - Cookie jar to use for request ...',
' delete - Perform blocking DELETE reque ...',
' delete_p - Same as "delete", but perform ...',
' get - Perform blocking GET request ...',
' get_p - Same as "get", but performs a ...',
' head - Perform blocking HEAD request ...',
' head_p - Same as "head", but performs ...',
' inactivity_timeout - Maximum amount of time in sec ...',
' insecure - Do not require a valid TLS ce ...',
' ioloop - Event loop object to use for ...',
' key - Path to TLS key file, default ...',
t/cpan/Mojo2/UserAgent.pm view on Meta::CPAN
package Mojo2::UserAgent;
use Mojo::Base 'Mojo::EventEmitter';
# "Fry: Since when is the Internet about robbing people of their privacy?
# Bender: August 6, 1991."
use Mojo::IOLoop;
use Mojo::Promise;
use Mojo::Util qw(monkey_patch term_escape);
use Mojo::UserAgent::CookieJar;
use Mojo::UserAgent::Proxy;
use Mojo::UserAgent::Server;
use Mojo::UserAgent::Transactor;
use Scalar::Util qw(weaken);
use constant DEBUG => $ENV{MOJO_CLIENT_DEBUG} || 0;
has ca => sub { $ENV{MOJO_CA_FILE} };
has cert => sub { $ENV{MOJO_CERT_FILE} };
has connect_timeout => sub { $ENV{MOJO_CONNECT_TIMEOUT} || 10 };
has cookie_jar => sub { Mojo::UserAgent::CookieJar->new };
has inactivity_timeout => sub { $ENV{MOJO_INACTIVITY_TIMEOUT} // 40 };
has insecure => sub { $ENV{MOJO_INSECURE} };
has 'max_response_size';
has ioloop => sub { Mojo::IOLoop->new };
has key => sub { $ENV{MOJO_KEY_FILE} };
has max_connections => 5;
has max_redirects => sub { $ENV{MOJO_MAX_REDIRECTS} || 0 };
has proxy => sub { Mojo::UserAgent::Proxy->new };
has request_timeout => sub { $ENV{MOJO_REQUEST_TIMEOUT} // 0 };
has server => sub { Mojo::UserAgent::Server->new( ioloop => shift->ioloop ) };
t/cpan/Mojo2/UserAgent.pm view on Meta::CPAN
cookie, multipart, gzip compression and multiple event loop support.
All connections will be reset automatically if a new process has been forked, this allows multiple processes to share
the same L<Mojo::UserAgent> object safely.
For better scalability (epoll, kqueue) and to provide non-blocking name resolution, SOCKS5 as well as TLS support, the
optional modules L<EV> (4.32+), L<Net::DNS::Native> (0.15+), L<IO::Socket::Socks> (0.64+) and L<IO::Socket::SSL>
(2.009+) will be used automatically if possible. Individual features can also be disabled with the C<MOJO_NO_NNR>,
C<MOJO_NO_SOCKS> and C<MOJO_NO_TLS> environment variables.
See L<Mojolicious::Guides::Cookbook/"USER AGENT"> for more.
=head1 EVENTS
L<Mojo::UserAgent> inherits all events from L<Mojo::EventEmitter> and can emit the following new ones.
=head2 prepare
$ua->on(prepare => sub ($ua, $tx) {...});
Emitted whenever a new transaction is being prepared, before relative URLs are rewritten and cookies added. This
t/cpan/Mojo2/UserAgent.pm view on Meta::CPAN
my $timeout = $ua->connect_timeout;
$ua = $ua->connect_timeout(5);
Maximum amount of time in seconds establishing a connection may take before getting canceled, defaults to the value of
the C<MOJO_CONNECT_TIMEOUT> environment variable or C<10>.
=head2 cookie_jar
my $cookie_jar = $ua->cookie_jar;
$ua = $ua->cookie_jar(Mojo::UserAgent::CookieJar->new);
Cookie jar to use for requests performed by this user agent, defaults to a L<Mojo::UserAgent::CookieJar> object.
# Ignore all cookies
$ua->cookie_jar->ignore(sub { 1 });
# Ignore cookies for public suffixes
my $ps = IO::Socket::SSL::PublicSuffix->default;
$ua->cookie_jar->ignore(sub ($cookie) {
return undef unless my $domain = $cookie->domain;
return ($ps->public_suffix($domain))[0] eq '';
});
# Add custom cookie to the jar
$ua->cookie_jar->add(
Mojo::Cookie::Response->new(
name => 'foo',
value => 'bar',
domain => 'docs.mojolicious.org',
path => '/Mojolicious'
)
);
=head2 inactivity_timeout
my $timeout = $ua->inactivity_timeout;
( run in 0.688 second using v1.01-cache-2.11-cpan-e9199f4ba4c )