I need to convert LWP::UserAgent to Mojo::UserAgent to support async calls. Problem is I couldn't find the exact methods that matches the LWP::UserAgent methods below, for example, how do I convert the following LWP methods over to Mojo's? Any insight is greatly appreciated!
my $ua = new LWP::UserAgent ;
$ua->protocols_allowed( [ 'http', 'https' ] );
$ua->ssl_opts(
SSL_version=>'TLSv12',
verify_hostname=>0,
SSL_verify_mode=>SSL_VERIFY_NONE,
SSL_ca_file=>'ca_file.crt',
SSL_cert_file=>'cert_file.crt',
SSL_key_file=>'key_file.key',
SSL_passwd_cb=> sub { return 'psswd'; }
);
$ua->credentials( $host_port, $realm, $user, $password ) ;
$ua->timeout( $timeOut ) ;
$ua->proxy( $theProxy ) ;
$ua->request( $requestObj );
By reading the documentation pages for LWP::UserAgent and Mojo::UserAgent, here is what I can see:
$ua->protocols_allowed(): This function is not available inMojo::UserAgentSSL_version: can be set forMojo::UserAgentby callingIO::Socket::SSL::SSL_version()verify_hostname: If verification is wanted, it can be called explicitly by callingIO::Socket::SSL::verify_hostname()SSL_verify_mode: Can be set by callingIO::Socket::SSL::set_defaults(SSL_verify_mode => $mode)SSL_ca_file:Mojo::UserAgenthas a method$ua->ca()that can be used.SSL_cert_file:Mojo::UserAgenthas a method$ua->cert()that can be usedSSL_key_file:Mojo::UserAgenthas a method$ua->key()that can be usedSSL_passwd_cb: Can be set by callingIO::Socket::SSL::set_defaults(SSL_passwd_cb => $cb)$ua->credentials: I think these can be set by constructing a Mojo::URL object and passing it to the relevant request method.$ua->timeout():Mojo::UserAgenthas a method$ua->connect_timeout()that can be used$ua->proxy():Mojo::UserAgenthas a method$ua->proxy()that can be used.$ua->request():Mojo::UserAgenthas a methods$ua->start()and$ua->start_p()that can be used.