AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Netzwerke Daten abholen von einem CakePHP Server
Thema durchsuchen
Ansicht
Themen-Optionen

Daten abholen von einem CakePHP Server

Ein Thema von MartinK · begonnen am 4. Okt 2014 · letzter Beitrag vom 8. Jan 2015
 
MartinK

Registriert seit: 21. Jun 2009
Ort: Germering (Germany)
89 Beiträge
 
Delphi 10.2 Tokyo Enterprise
 
#16

AW: Daten abholen von einem CakePHP Server

  Alt 29. Okt 2014, 15:27
Nachdem jetzt mit direktem www Zugang alles klappt, habe ich noch ein Thema sobald ich via Proxy verbinde

hier mal ein Stück Code das bei mir heraussucht welche Art von Proxy-Auth gemacht wird
Delphi-Quellcode:
procedure TForm1.IdHTTPProxyAuthorization(Sender: TObject; Authentication: TIdAuthentication; var Handled: Boolean);
begin
  Handled := False;
end;

function TForm1.IdSSLIOHandlerSocketOpenSSLVerifyPeer(Certificate: TIdX509; AOk: Boolean; ADepth, AError: Integer): Boolean;
begin
  Result := True;
end;


procedure TForm1.IdHTTPSelectProxyAuthorization(Sender: TObject; var AuthenticationClass: TIdAuthenticationClass; AuthInfo: TIdHeaderList);

begin
  ProxyAuthTxt := 'Proxy-Authentification: Unkown';

  // First check for NTLM authentication, as you do not need to set username and password because Indy will automatically
  // handle passing your Windows Domain username and password to the proxy server
  if (pos('Proxy-Authenticate: NTLM', IdHTTP.Response.RawHeaders.Text)>0)
    then begin
           IdHTTP.ProxyParams.BasicAuthentication := false;
           AuthenticationClass := TIdSSPINTLMAuthentication;
           ProxyAuthTxt := 'Proxy-Authentific.: NTML (w/o Username+PW)';
           ProxyAuthType := 1;
         end
    else begin
           //...now check for Basic Authentication
           if (pos('Proxy-Authenticate: Basic', IdHTTP.Response.RawHeaders.Text)>0)
             then begin
                    IdHTTP.ProxyParams.BasicAuthentication := true;
                    AuthenticationClass := TIdBasicAuthentication;
                    ProxyAuthTxt := 'Proxy-Authentification: Basic';
                    ProxyAuthType := 2;
                   end
             else begin
                    // Then Digest
                    if (pos('Proxy-Authenticate: Digest', IdHTTP.Response.RawHeaders.Text)>0)
                      then begin
                             IdHTTP.ProxyParams.BasicAuthentication := true;
                             AuthenticationClass := TIdDigestAuthentication;
                             ProxyAuthTxt := 'Proxy-Authentification: Digest';
                             ProxyAuthType := 3;
                           end;
                  end;
           //.------------
           IdHTTP.ProxyParams.ProxyUsername := EProxyUsername.Text;
           IdHTTP.ProxyParams.ProxyPassword := EProxyPassword.Text;
         end;

  LProxyAutent.Caption := ProxyAuthTxt;
end;

HTTP Get funktioniert auch einwandfrei solange ich ein normales get/Post mache,
"OHNE dem Server ein Username/Password für den Cloud-Zugriff mitzuübergeben"
(URL, Port und Pasword/Username wegen das proxys sind natürlcih angegeben passen !)


sobald ich den Cloud Username und Passwort mit angebe, bekomme ich beim "IdHttp.Get" eine Exception "HTTP/1.1 400 bad request"
Gehe ich ich aber nicht über den Proxy, sondern verbinde direkt, dann funktioniert der Code eiwandfrei;

Delphi-Quellcode:
Function TForm1.Ask4aCloudResponse(aUsername, aPassword, aServerURL, aServerCommand: String ):String;
begin
  try
    IdHTTP.HandleRedirects := True;

    iDHTTP.Request.BasicAuthentication := True;
    iDHTTP.Request.Authentication := TIdBasicAuthentication.Create;
    iDHTTP.Request.Authentication.Username := aUsername;
    iDHTTP.Request.Authentication.Password := aPassword;
    IdHTTP.Request.ContentType := 'application/json';
    Result := IdHttp.Get(aServerURL + aServerCommand);
  finally
    ;
  end;
end;
woran kann denn das liegen?
Martin Kuhn
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:50 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz