Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   HTTP Download mit IdHTTP analog zu curl (https://www.delphipraxis.net/154816-http-download-mit-idhttp-analog-zu-curl.html)

Paul Schmidt 26. Sep 2010 18:33

HTTP Download mit IdHTTP analog zu curl
 
Hallo Delphi Gemeinde,

ich hoffe, ihr könnt mir bei meinem Problem weiterhelfen:

ich möchte eine Datei mittels IdHTTP von einer URL mit Auth herunterladen.
Die Seite/Download ist mittels username/passwort geschützt.
Wenn ich das ganze mittels curl teste, funktioniert es.
Über IdHTTP (request) bekommen ich immer nur die Serverantwort, dass dieser
meine Anfrage nicht versteht bzw. das login falsch wäre.

Nun stehe ich irgendwie auf dem Schlauch und komme nicht weiter. :(
Funktionieren denn Anfragen/Downloads, welche mit curl klappen so ohne weiteres
mit mit IdHTTP ?

Viele Grüße,
Paul

ps: Hierfür gibts ja auch "curlpas". Allerdings möchte ich, wenn es geht,
darauf verzichten und die Delphi-eigenen Boardmittel einsetzen

SirThornberry 26. Sep 2010 18:56

AW: HTTP Download mit IdHTTP analog zu curl
 
Eigentlich sollte es ohne Probleme funktionieren. Wie sieht denn dein bisheriger Quelltext aus?
Und funktioniert die Passwortabfrage auf der Seite per Formular innerhalb der Webseite oder per Dialog (geschützter Bereich)?

Paul Schmidt 26. Sep 2010 19:13

AW: HTTP Download mit IdHTTP analog zu curl
 
als Testcode völlig simple:
Delphi-Quellcode:
var
  stream:TFilestream;
begin
  stream:=TFilestream.create('C:\foo.zip',fmcreate) ;
  idhttp1.Request.Username := 'username';
  idhttp1.Request.Password := 'password';
  idhttp1.Get('url',stream);
  idhttp1.disconnect;
  FreeAndNil(stream);
end;

Das Login auf der Seite funktioniert. Die login-Abfrage kommt.

Allerdings ist das Ergebnis als "foo.zip":
"Authorization Required

This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.
------------------------------------
Apache Server at..."

sx2008 26. Sep 2010 20:05

AW: HTTP Download mit IdHTTP analog zu curl
 
da fehlt noch
Delphi-Quellcode:
idhttp1.Request.BasicAuthentication := true;

Paul Schmidt 28. Sep 2010 18:33

AW: HTTP Download mit IdHTTP analog zu curl
 
Zitat:

Zitat von sx2008 (Beitrag 1052256)
da fehlt noch
Delphi-Quellcode:
idhttp1.Request.BasicAuthentication := true;

Hatte ich vergessen zu erwähnen: hatte ich bereits auf true gesetzt.

Hallo,

besten Dank für eure Tipps!

Allerdings sah die Lösung hierbei etwas anders aus:
das login musste ich als Post senden, um daraufhin den Download zu erhalten.

Daher: Problem gelöst.

Es grüßt,
der Paul


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:46 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz