in reply to 400 URL must be absolute

That URL is wrong on so many levels.

First of all, LWP::UserAgent expects the protocol name at the beginning of the URL. In your case, that would be "http://". (This is insecure, and you should really be using https, but whatever).

The port number would go after the hostname, before the rest of the URI (e.g. "the path on the server"). So that would be http://hostname:80/foo/bart/baz

Since you are using HTTP and the default port for HTTP is 80, you don't need to specify the port number.

So the URI you want to use, i assume is:

http://88.159.57.235/roots/lines/wielinga/wie-aaa/wie-sle/wie-hee/wie-bru/index.htm

Since you use basic auth, you should be able to just paste the URI into your browser and get the authentication prompt to verify. Works for me.

More information:

perl -e 'use Crypt::Digest::SHA256 qw[sha256_hex]; print substr(sha256_hex("the Answer To Life, The Universe And Everything"), 6, 2), "\n";'

Replies are listed 'Best First'.
Re^2: 400 URL must be absolute
by Wijnand (Initiate) on Apr 05, 2022 at 09:26 UTC

    Thanks a lot, it helps me with the "400 URL must be absolute" error. I'm not a programmer, let alone a "PerlMonk". I have to get my knowledge from what I can find on the internet and that is not always clear.

    But... now i get a "401 Unauthorized" error. Because I know now the URL must be OK and the user and password are OK, the problem must be the realm (?). I got the in de sub given realm with the script:

    lwp-request -e http://88.159.57.235/roots/lines/wielinga/wie-aaa/wie-s +le/wie-hee/wie-bru/pien.htm

    with the response:

    401 Unauthorized Connection: close Date: Tue, 05 Apr 2022 09:21:04 GMT Accept-Ranges: bytes ETag: "8b2-5d3194c961ede" Server: Apache/2.4.41 (Ubuntu) WWW-Authenticate: Basic realm="Maintenance Guard" Content-Length: 2226 Content-Type: text/html Last-Modified: Tue, 14 Dec 2021 11:14:56 GMT Client-Date: Tue, 05 Apr 2022 09:21:04 GMT Client-Peer: 88.159.57.235:80 Client-Response-Num: 1 Title: Customized Error 401 X-Meta-Author: W.J.Nijs X-Meta-Robots: noindex

    Is there an other way to get the right realm?

      Your code in the original post say real='Privacy Guard', but the lwp-request headers ask for realm='Maintenance Guard'.

      So the correct realm on your code would be 'Maintenance Guard', i guess.

      Also make sure you get upper/lowercase of all authentication fields correct (username, password, realm).

      I can't really test your setup. For that, i would need username+password, but i will never ask for that unless you are a paying customer of my employer due to all sorts of legal and insurance reasons. So do not post the authentication data. The only thing i can advise you to do is to check if your authentication data is correct by using your browser to log in.

      perl -e 'use Crypt::Digest::SHA256 qw[sha256_hex]; print substr(sha256_hex("the Answer To Life, The Universe And Everything"), 6, 2), "\n";'

      Or have i use the URI instead of the URL for $url with the user and pass in the URI? Is that save?

        You have been using http instead of https throughout so nothing is safe.


        🦛

        use the URI instead of the URL

        Recommended reading: The Difference Between a URL, URI, and a URN

        Every URL is an URI, but not every URI is an URL. URLs can have a userinfo part, but nowadays that is considered insecure (especially if a password is included) and rarely used anymore.