Philipp Hasenfratz: Datein aus passwortgeschüztem Bereich laden

Beitrag lesen

Halihallo Valentin

Dazu wollte ich jetzt mit LWP eine Anfrage machen, weiss aber nich wie in Passwort und Benutzername automatisch übergeben kann. Bis jetzt habe ich nur die Variante http://Username:Passwort@Url gefunden. Das funktioniert z.B. bei Testversuchen im IE. So richtig normal kommt mir das aber nicht vor.

Die Übergabe der Authentifizierung über URL ist _nicht_ Standard!

Gibts bei der Variante Benutzeranme und Passwort in der ULR zu übergeben irgendwelche Probleme? Und gibt es eine bessere Art das mit LWP zu lössen?

Ja. RTFM!

perldoc lwpcook  (Topic "access to protected documents" bzw. gleichnamiger Ancor)

<cite>
ACCESS TO PROTECTED DOCUMENTS
Documents protected by basic authorization can easily be accessed like this:

use LWP::UserAgent;
  $ua = LWP::UserAgent->new;
  $req = HTTP::Request->new(GET => 'http://www.linpro.no/secret/');
  $req->authorization_basic('aas', 'mypassword');
  print $ua->request($req)->as_string;
The other alternative is to provide a subclass of LWP::UserAgent that overrides the get_basic_credentials() method. Study the lwp-request program for an example of this.
</cite>

Viele Grüsse

Philipp