Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

400 URL must be absolute

by Win (Novice)
on Dec 17, 2007 at 15:31 UTC ( #657435=perlquestion: print w/replies, xml ) Need Help??
Win has asked for the wisdom of the Perl Monks concerning the following question:

Please could a monk explain why:
#!/usr/bin/perl use warnings; use strict; use LWP::UserAgent; use HTTP::Request::Common; #unless ( scalar @ARGV == 1 ) { ... } # Apparently that would have b +een an alternative if ($#ARGV != 0) { print STDERR "Usage: $0 \"URL to fetch\"\n"; exit; } my $agent = new LWP::UserAgent; $agent->proxy(['http','ftp'],' +-5.808/lib/LWP/');
gives me the following error message:
400 URL must be absolute

Replies are listed 'Best First'.
Re: 400 URL must be absolute
by shmem (Chancellor) on Dec 17, 2007 at 15:47 UTC
    You haven't posted the entire script - for instance, the processing of $ARGV[0] is lacking.

    Then, isn't a valid HTTP Proxy address. A HTTP Proxy is basically (sort of) a web server which asks other web servers on behalf of the connecting client, and that's not what you get addressing a single file on the CPAN search server.


    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      I just want to pull in the contents of a web page and put it into a folder. Am I on the right track with this?
        Did you read the documentation? Or shmem's comments? You need to start making some effort. See LWP::UserAgent for details of what $agent->proxy(['http','ftp'],''); does, and what a proxy server is, since you don't seem to understand this concept either. Once again, well done for not reading the replies you get to your questions.

Re: 400 URL must be absolute
by moritz (Cardinal) on Dec 17, 2007 at 15:39 UTC
    I can't reproduce your error, the script runs fine for me.

    Perhaps you should tell us which argument you provided to your script that made it fail.

    As oha explain in the CB, HTTP requests have to use absolute URLs, mostly likely you provided a relative URL somewhere.

    BTW it's quite weird to use a HTML page as a proxy URL.

      The url that I have used is included in the code.

      Is there something about what you have said that I have not understood?
        probably you do not understood what's a proxy as moritz was saying.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://657435]
Approved by moritz
[choroba]: Email::Address DoS
[Corion]: (that module has been deprecated by its author already, so that's fair. Although I wonder why the backtracking can't be fixed to handle the formfeeds gracefully)
[choroba]: not enough tuits?
[Corion]: choroba: Yeah, maybe. I'm also unaware of who uses Email:: modules, but that's more my limited horizon of things ;)

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2018-06-20 11:56 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (116 votes). Check out past polls.