[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

LWP and auto-relocation: Turning Off?

Posted on 2000-05-10
8
Medium Priority
?
217 Views
Last Modified: 2010-03-05
I am using Perl 5.6 on Windows 98. I am using LWP to make http requests to websites.  I notice it auto relocates to new locations when a website sends back its 320 Reloc response.  I want to get back the full response and have LWP "not" auto relocate.

One little extra question: how do I get TIMEOUT to work?  I am connecting to a proxy or trying to retrieve a GIF and the server is not accepting the request or is taking too long to fill the request.  How do I set the timeout for accepting a request AND for a server to fill the request in its entirety?  $UA->TIMEOUT(10)  just doesn't seem to work when I connect to no-existant proxies or websites.  It just seems to timeout at its default 3 mins or somethine.

Thanks

How do I do this?
0
Comment
Question by:ljaques
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 8

Accepted Solution

by:
shlomoy earned 20 total points
ID: 2798967
use LWP::Simple qw($ua);

$url_str = "http://www.av/com/";
$file = "/tmp/myfile";

$ua->timeout(10);
my ($request, $response);

$request = HTTP::Request->new(GET => $url_str);
$response = $ua->request($request, $file);


-------
$response holds an HTTP::Response object which you can query for the exact return code, and act accordingly.

The timeout might not work for you because you didn't request for $ua when you use LWP::Simple.
0
 

Author Comment

by:ljaques
ID: 2799295
Hi shlomoy.

This is the code I'm using:

---
use LWP::Simple qw($ua);

$url_str = "http://www.av/com/";
$file = "/tmp/myfile";

$ua->timeout(20);
my ($request, $response);
$ua->proxy(http,"http://922.2.122.106:80");

$request = HTTP::Request->new(GET => $url_str);
print "Requesting...\n";
$response = $ua->request($request);
print $response->as_string;
---

LWP will try to connect to the proxy first and find that it doesn't exist.  It returns back "500 Internal error (Timeout)"  which is great but it takes at least 1 minute to timeout.  It seems to ignore $ua->timeout(20).  I would love to have it timeout in 20 secs.  Is $ua->timeout only good for timingout  on data that is presently sending back but is taking too long to complete?  I would love to have control over this as well as conncection timeout.

Thanks for any extra help
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2800467
in your code you are using us, but it seems you have not created an UserAgent object!!

add the foll line....
$ua= new LWP::UserAgent;


BEFORE ....

$ua->timeout(20);


Also add the foll line...

print "Content-type: text/html\n\n";

BEFORE ....

print "Requesting...\n";

Let me know how it goes.

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:ljaques
ID: 2802048
Hi again guys.

I placed in the $ua=new LWP::UserAgent into the code above as suggested but it still doesn't timeout in 10 secs or 20 secs.  It times out in its own hard wired 1 minute or so.

Maybe it has something to do with it running in MSDOS (I have Windows 98 using Perl 5.6 from Active State).

Thanks for any more help.
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2802147
what about the redirection??

is that still happening too??

0
 
LVL 12

Expert Comment

by:geotiger
ID: 2807431
listening ...
0
 

Author Comment

by:ljaques
ID: 2807493
yes for redirection still happening.  :(
Though I am more interested in the timeout problem.  At least I would love to have LWP timeout any dead remote connections (ie. proxies or remote site) by 30 secs.  

Thanks.
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2810816
"I... have Windows 98 using Perl 5.6 from Active State). ...."

Hmm!! can you try the same program using older version of PERL??

just a few Q's back another user had a problem using sockets on PERL 5.6. it was solved when the user went back to the older version.

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question