![]() |
HTTP-Post mit idHTTP.DoRequest funktioniert nicht
Hallo zusammen!
Ich schreibe gerade einen Proxy-Server welcher mit einem Parent-Proxy arbeiten soll. Sinn des ganzen ist es die aufgerufenen Internetseiten zu kontrollieren bzw. nur eine ganz bestimmte Site zu erlauben. Nun zum Problem: Das Aufrufen von Webseiten funktioniert gut aber Anmeldungen die ein HTTP-Post Kommando benutzen klappen einfach nicht. Dabei wird einfach die Anmeldeseite nochmal geladen... Weiß Jemand Rat?
Delphi-Quellcode:
("Log" schreibt Einträge in eine Listbox um zu sehen was da vor sich geht...)
procedure TfrmMain.IdHttpServerCommandGet(AThread: TIdPeerThread;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); var UrlStr: AnsiString; Method: TIdHTTPMethod; idHttpClient: TidHttp; begin try AResponseInfo.ResponseNo := 501; Log('KOMMANDO: '+ARequestInfo.RawHTTPCommand); UrlStr := 'http://'+ARequestInfo.Host+ARequestInfo.Document; if Length(ARequestInfo.QueryParams) > 0 then UrlStr := UrlStr+'?'+ARequestInfo.QueryParams; idHttpClient := TidHttp.Create(nil); try with idHttpClient do begin with ProxyParams do begin BasicAuthentication := True; ProxyServer := 'ParentProxy'; ProxyPort := 8080; ProxyUsername := 'MyUsername'; ProxyPassword := 'MyPassword'; end; HandleRedirects := True; RedirectMaximum := 15; if ARequestInfo.Command = 'GET' then Method := hmGet else if ARequestInfo.Command = 'POST' then Method := hmPost else if ARequestInfo.Command = 'HEAD' then Method := hmHead else begin Log('FEHLER: Unbekanntes Kommando'); Exit; end; if Method <> hmHead then begin AResponseInfo.ContentStream := TMemoryStream.Create; if Method = hmPost then ARequestInfo.PostStream := TMemoryStream.Create; end; try DoRequest(Method, UrlStr, ARequestInfo.PostStream, AResponseInfo.ContentStream); finally with Response do begin AResponseInfo.ResponseNo := ResponseCode; AResponseInfo.ResponseText := ResponseText; AResponseInfo.RawHeaders.Assign(RawHeaders); end; end; end; finally idHttpClient.Free; end; except on E: Exception do Log('FEHLER: '+E.Message); end; end; Habe in der DP viele ähnliche Einträge gefunden (daraus wurden auch diese Code-Zeilen zusammengewürfelt) aber nichts was wirklich auf Anhieb funktioniert hätte... |
Re: HTTP-Post mit idHTTP.DoRequest funktioniert nicht
du musst auch die Request-Header weiterleiten - vor allem
Content-Type! schaue dir den Netzwerk-Traffic doch mal mit Ethereal ![]() Gruss Hinnack |
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:45 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