lwp-useragent

How to test an HTTP header value using LWP::UserAgent

China☆狼群 提交于 2019-12-11 09:39:42
问题 I may be posting more questions as I get answers, but here goes! I am currently trying to troubleshoot a Perl script that my university used to use to automatically download files with SAT score data. The idea is to read through emails in a certain account; pull out the cycle number (which is used in the URL); piece together multiple URLs; and then use LWP::UserAgent to grab the files from the server and do other Perl magicks on them. In my investigation I have determined that manually

LWP set max_size but still get content

为君一笑 提交于 2019-12-11 09:34:37
问题 I am using LWP to get the content from some sites and whenever the page size is larger than one megabyte, I would like LWP to stop downloading the page. This is accomplished with this code: my $ua = LWP::UserAgent->new; $ua->max_size(1024); And it works fine. The only problem is that even when the page is over 1mb, I would still like to be able to get the content of what it has downloaded so far. However, whenever I do this (the traditional way to get content with LWP when there are no errors

perl 500 proxy connect failed: PROXY ERROR HEADER, could be non-SSL URL

青春壹個敷衍的年華 提交于 2019-12-11 09:13:55
问题 have a problem when i try to connect with web service that have certification , username and password as credentials 500 proxy connect failed: PROXY ERROR HEADER, could be non-SSL URL My code is below: use LWP::Debug qw(+); use HTTP::Request::Common; use Crypt::SSLeay; use HTTP::Headers; use HTTP::Request; use LWP; $url = "https://ip:port/service"; my $ua = new LWP::UserAgent; $ENV{HTTPS_DEBUG} = 1; $ENV{HTTPS_PROXY} = 'https://ip:port'; $ENV{HTTPS_PROXY_USERNAME} = "username"; $ENV{HTTPS

Perl JSON::RPC::Client using LWP::Agent

心已入冬 提交于 2019-12-10 17:26:37
问题 I have been given requirements to not use the JSON::RPC::Client, instead use LWP to do the calls. Here is my code: Server: #!/usr/bin/perl use strict; use lib "."; use ServerLib; use JSON::RPC::Server::Daemon; die "Do Not run as Root\n" if($< == 0); print "Starting Daemon\n"; my $daemon = JSON::RPC::Server::Daemon->new(LocalPort => 8000); $daemon->dispatch({'/jsonrpc/API' => 'ServerLib'})->handle(); exit; Module: package ServerLib; use base qw(JSON::RPC::Procedure); # Perl 5.6 or more than

500 error with LWP:UserAgent

孤街醉人 提交于 2019-12-10 00:20:02
问题 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.

Perl: LWP::UserAgent returns always code 200 for redirected urls

↘锁芯ラ 提交于 2019-12-08 16:33:40
问题 I have a simple url which does a 302 temp. move to another page. I try to get to if the URL returns code 200 (for OK) to retrieve it and to stop if something else than 200 is returned. My code: my $ua = LWP::UserAgent->new( env_proxy => 1,keep_alive => 1, timeout => 30, agent => "Mozilla/4.76 [en] (Win98; U)"); my $response = $ua->get( $currenturl); print $response->code; The code above ALWAYS returns 200, even if its 302. I tested the header response using FireBug in Firefox. The URL returns

How to make a HTTP PUT request using LWP?

烈酒焚心 提交于 2019-12-07 03:58:50
问题 I'm trying to change this request to a HTTP PUT request, any idea how ? my $request = LWP::UserAgent->new; my $response = $request->get($url, "apikey", $apiKey, "requestDate", $requestDate); 回答1: You should use HTTP::Request: use LWP::UserAgent; use HTTP::Request; my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new("PUT", $url); my $res = $ua->request($req); 回答2: As of 6.04, LWP::UserAgent has a put helper, so you can now do: $ua->put( $url ) 回答3: PUT is HTTP::Request::Common. You can

I cannot Connect to any HTTPS site using LWP::UserAgent

笑着哭i 提交于 2019-12-07 02:32:22
问题 I am trying to create a script that simply just connect to a website. However, for some reason it will not connect to anything that is using HTTPS. We have a proxy enabled here. However, I believe the proxy is not the problem, because if I were to connect to an HTTPS inside the network that does not tunnel through a proxy it still fails. If I were to run this program on any site that is not using HTTPS, I can get through and the script works as intended. What I'm wondering is what could

handle lwp timeout effectively

半城伤御伤魂 提交于 2019-12-07 01:43:56
问题 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

How to make a HTTP PUT request using LWP?

☆樱花仙子☆ 提交于 2019-12-05 06:13:50
I'm trying to change this request to a HTTP PUT request, any idea how ? my $request = LWP::UserAgent->new; my $response = $request->get($url, "apikey", $apiKey, "requestDate", $requestDate); You should use HTTP::Request: use LWP::UserAgent; use HTTP::Request; my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new("PUT", $url); my $res = $ua->request($req); As of 6.04, LWP::UserAgent has a put helper, so you can now do: $ua->put( $url ) PUT is HTTP::Request::Common. You can build the request first and pass it into user agent. use HTTP::Request::Common; use LWP; $agent = LWP::UserAgent->new;