[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

specifying timeout in GET request ?????????

Posted on 1999-11-08
2
Medium Priority
?
143 Views
Last Modified: 2010-03-05
A Webget Client

#!/usr/bin/perl -w
    use IO::Socket;
    unless (@ARGV > 1) { die "usage: $0 host document ..." }
    $host = shift(@ARGV);
    $EOL = "\015\012";
    $BLANK = $EOL x 2;
    foreach $document ( @ARGV ) {
        $remote = IO::Socket::INET->new( Proto     => "tcp",
                                         PeerAddr  => $host,
                                         PeerPort  => "http(80)",
                                        );
        unless ($remote) { die "cannot connect to http daemon on $host" }
        $remote->autoflush(1);
        print $remote "GET $document HTTP/1.0" . $BLANK;
        while ( <$remote> ) { print }
        close $remote;
    }


Using the above script I can get html documents ...


BUt suppose the document is say 2 MB and there is a server timeout . I dont want the script to wait endlessly..

I want to set the timeout of the GET request .. is it possible ..

The script should request the document and if it is not getting the document within the SET timeout it should come back from the routine

help

BTW using the above routine I am able to access

"www.yahoo.com" type of addressess but Im
NOT able to retrieve

"username.hypermart.net" kind of documents

is there a solution ?



chris

0
Comment
Question by:christopher sagayam
2 Comments
 
LVL 8

Accepted Solution

by:
jhurst earned 0 total points
ID: 2192127
There is no timeout that you can set in the http-header when you make the request.  The spec is on line at:  www.w3.org.

As to the user.hypermart.net problem.  This is because they are using virtual hosting and require that the http_host be set.  You can do this by adding a:

print "Host: user.hypermart.net" . $BLANK;

and changing the $BLANK to an $EOL in the GET line.
0
 
LVL 6

Author Comment

by:christopher sagayam
ID: 2192161
thanks
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

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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
Suggested Courses

612 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