Einzelnen Beitrag anzeigen

Benutzerbild von RWarnecke
RWarnecke

Registriert seit: 31. Dez 2004
Ort: Stuttgart
4.408 Beiträge
 
Delphi XE8 Enterprise
 
#6

Re: IdHTTP + Proxy + Anmeldung am Proxy mit eigenem Fenster

  Alt 4. Jul 2007, 08:39
Hallo zusammen,

ich habe jetzt die Lösung gefunden

Ihr müsst den Wert hoInProcessAuth auf True setzen. Dann verwendet Ihr folgendes Beispiel :
Delphi-Quellcode:
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
  IdHTTP, IdAuthentication;

type
  TForm2 = class(TForm)
    IdHTTP1: TIdHTTP;
    Label1: TLabel;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure IdHTTP1ProxyAuthorization(Sender: TObject;
      Authentication: TIdAuthentication; var Handled: Boolean);
  private
    procedure ConfigIdHTTP;
  public
    { Public-Deklarationen } 
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm} 

uses
  Unit3;

procedure TForm2.ConfigIdHTTP;
begin
  IdHTTP1.ProxyParams.ProxyServer := 'proxy.domain.de';
  IdHTTP1.ProxyParams.ProxyPort := 8080;
  IdHTTP1.ProxyParams.BasicAuthentication := true;
  Label1.Caption := IdHTTP1.Get('http://ip.smartcoder.net/txt/');
end;

procedure TForm2.IdHTTP1ProxyAuthorization(Sender: TObject;
  Authentication: TIdAuthentication; var Handled: Boolean);
begin
  if Form3.ShowModal = mrOK then
  begin
    Authentication.Username := Form3.LabeledEdit1.Text;
    Authentication.Password := Form3.LabeledEdit2.Text;
  end;
end;

procedure TForm2.Button1Click(Sender: TObject);
begin
  ConfigIdHTTP;
end;

end.
Damit sollte die Proxyauthentifizierung funktionieren. So tut es zumindest bei mir. Über Feedback ob die Beispiel-Unit funktioniert wäre ich sehr dankbar, Würde dann auch nochmal einen Beitrag verfassen für die Code-Library.
Rolf Warnecke
App4Mission
  Mit Zitat antworten Zitat