lwp-useragent

handle lwp timeout effectively

六月ゝ 毕业季﹏ 提交于 2019-12-05 05:41:39
I am using LWP to download content from web pages, and I would like to limit the amount of time it waits for a page. This is accomplished in lwp like this: my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->get($url); And this works fine, except for whenever the timeout reaches its limit, it just dies and I can't continue on with the script! I'd really like to handle this timeout properly so that I can record that the url had a timeout and then move on to my next one. Does anyone know how to do this? Thanks! LWP::Agent 's get() returns a HTTP::Response object that you can use for checking

500 error with LWP:UserAgent

三世轮回 提交于 2019-12-04 21:08:13
Solved ! thanks for every help i had :) Found http://stackoverflow.com/questions/8026524/how-do-i-force-lwp-to-use-cryptssleay-for-https-requests and solved my issue with use Net::SSL (); # From Crypt-SSLeay BEGIN { $Net::HTTPS::SSL_SOCKET_CLASS = "Net::SSL"; # Force use of Net::SSL $ENV{HTTPS_PROXY} = 'http://10.0.3.1:3128'; } I tried a thousand different ways to connect to the URL https://sis-t.redsys.es:25443/sis/entradaXMLEntidad/ and i seem unable to get something else than a 500 error. Latest code i tried was require LWP::UserAgent; ## Code added according to Sinan Ünür s comment use Net

LWP::UserAgent HTTP Basic Authentication

痴心易碎 提交于 2019-12-04 03:05:33
I tried to run this perl5 program: #!/usr/bin/env perl use strict; use warnings; use LWP; my $ua = LWP::UserAgent->new('Mozilla'); $ua->credentials("test.server.com:39272", "realm-name", 'user_name', 'some_pass'); my $res = $ua->get('http://test.server.com:39272/'); print $res->content; On other hand I have HTTP::Daemon: #!/usr/bin/env perl use strict; use warnings; use HTTP::Daemon; my $hd = HTTP::Daemon->new or die; print "Contact URL: ", $hd->url, "\n"; while (my $hc = $hd->accept) { while (my $hr = $hc->get_request) { if ($hr->method eq 'GET') { print $hr->as_string, "\n"; } } $hc->close;

Is LWP::UserAgent not thread-safe?

六眼飞鱼酱① 提交于 2019-12-02 05:28:20
问题 I'm running 40-or-so threads with the following subroutine: my $app = shift; my $ua = LWP::UserAgent->new(); $ua->timeout(5); my $response = $ua->get($$app{'watch_url'}); my $new_md5; if ($response->is_success()) { $new_md5 = md5_hex($response->content()); } return ($$app{'short_name'}, $$app{'watch_md5'}, $new_md5); Core dumps ensue about 3/4 of the time. LWP and LWP::UserAgent are pure Perl, so I'm caught off-guard by this. Is LWP::UserAgent not thread-safe? Update: Here's a minimal version

Why don't my LWP::UserAgent credentials work?

萝らか妹 提交于 2019-11-30 03:13:23
问题 I'm trying to access a protected file. Server is using digest authentication - which I can see from the printed out response. Here is the sample code: use LWP; use strict; my $url = 'http://somesite.com/aa/bb/cc.html'; my $username = 'scott'; my $password = 'tiger'; my $browser = LWP::UserAgent->new('Mozilla'); $browser->credentials("http://somesite.com:80","realm-name",$username=>$password); my $response=$browser->get($url); print $response->content; Name of the realm I got it from the popup

How to enforce a definite timeout in perl?

房东的猫 提交于 2019-11-29 11:27:14
I am using LWP to download content from web pages, and I would like to limit the amount of time it waits for a page. my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy; $response = $ua->get("http://XML File"); $content = $response->decoded_content; The problem is that the server will occasionally deadlock (we're trying to figure out why) and the request will never succeed. Since the server thinks it is live, it keeps the socket connection open thus LWP::UserAgent's timeout value does us no good what-so-ever. What is the best way to enforce an absolute timeout on a request? Whenever

HTTPS Proxy and LWP::UserAgent

老子叫甜甜 提交于 2019-11-27 22:27:27
问题 I have read a number of threads on a number of sites and am still unable to make this work. I have a client machine (OSX) with OpenSSL 0.9.8r running perl 5.12.4, with LWP 6.0.4, updated Crypt::SSLeay, Net::SSL etc. I am trying to connect to an HTTPS site (https://github.com in the example) via a WinGate proxy that I have running on a Windows VM. Note that my actual application is attaching to an SSL webservice that I have no control over. From Firefox, pointed to the proxy everything is