![]() |
Indy TIdHTTP mit SSL und GZip
Liste der Anhänge anzeigen (Anzahl: 1)
Moin!
Ich bekomme einfach die Kombination HTTPS+GZip Encoding nicht zum Laufen. Zum Testen habe ich eine ganz simple Anwendung zusammengeklickt:
Delphi-Quellcode:
DFM:
procedure TForm1.Button1Click(Sender: TObject);
begin if IdHTTP1.Compressor.IsReady then begin IdHTTP1.Get('https://www.google.de/'); end else begin ShowMessage('ZLib nicht bereit'); end; end;
Delphi-Quellcode:
Schaue ich mir den Request dann im Wireshark an (siehe Bild unten), funktioniert zwar TLS 1.2 ganz wunderbar, allerdings wird schon im Client Hello keinerlei Compression Method angefragt. Entsprechend ist es dem Server auch völlig Wumpe und antwortet unkomprimiert.
object IdHTTP1: TIdHTTP
IOHandler = IdSSLIOHandlerSocketOpenSSL1 AllowCookies = True ProxyParams.BasicAuthentication = False ProxyParams.ProxyPort = 0 Request.ContentLength = -1 Request.ContentRangeEnd = -1 Request.ContentRangeStart = -1 Request.ContentRangeInstanceLength = -1 Request.Accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' Request.BasicAuthentication = False Request.UserAgent = 'Mozilla/3.0 (compatible; Indy Library)' Request.Ranges.Units = 'bytes' Request.Ranges = <> HTTPOptions = [hoForceEncodeParams] Compressor = IdCompressorZLib1 Left = 668 Top = 225 end object IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL MaxLineAction = maException Port = 0 DefaultPort = 0 SSLOptions.Method = sslvTLSv1_2 SSLOptions.SSLVersions = [sslvTLSv1_2] SSLOptions.Mode = sslmUnassigned SSLOptions.VerifyMode = [] SSLOptions.VerifyDepth = 0 Left = 676 Top = 289 end object IdCompressorZLib1: TIdCompressorZLib Left = 772 Top = 265 end Die ZLib ist offensichtlich geladen, sonst würde der Request gar nicht abgesetzt. Ich habe auch schon versucht, in den
Delphi-Quellcode:
zu setzen. In manchen Tutorials heißt es, man soll das explizit setzen, in anderen Tutorials wiederum heißt es gerade NICHT setzen. Es geht aber weder MIT noch OHNE AcceptEncoding.
RequestParams.AcceptEncoding := 'gzip, deflate'
Grüße Cody |
AW: Indy TIdHTTP mit SSL und GZip
Ich glaube da fehlt noch sowas wie
Delphi-Quellcode:
IdHttp.Request.AcceptEncoding := 'gzip, deflate';
|
AW: Indy TIdHTTP mit SSL und GZip
Zitat:
|
AW: Indy TIdHTTP mit SSL und GZip
arg, ne, augen waren nur auf source, tut mir leid!
|
AW: Indy TIdHTTP mit SSL und GZip
Delphi-Quellcode:
IdHTTP1.Request.AcceptEncoding := 'gzip, deflate;q=1.0, *;q=0';
So sollte es forciert werden und wenn Server das nicht kann gibts 406 (not acceptable). Ps: die zlib dll sollte sich im .exe verzeichnis befinden. |
AW: Indy TIdHTTP mit SSL und GZip
Zitat:
|
AW: Indy TIdHTTP mit SSL und GZip
So wie ich mich jetzt gerade belesen habe ist das möglicherweise gar kein Bug sondern so gewollt. Die Kombination von SSL und Stream Compression öffnet wohl Sicherheitslücken.
|
AW: Indy TIdHTTP mit SSL und GZip
Vor einiger Zeit hatte ich das gleiche Problem.
Ich habe es mit Indy (Delphi 10.3) folgendermaßen gelöst: 1. IdHTTP 2. IdCompressorZLib 3. IdCompressionIntercept (nicht getestet, ob diese Indy-Komponente wirklich erforderlich ist) Wichtig ist: GetPage muss zweimal aufgerufen werden.
Delphi-Quellcode:
object IdHTTP1: TIdHTTP
Intercept = IdCompressionIntercept1 AllowCookies = True HandleRedirects = True ProxyParams.BasicAuthentication = False ProxyParams.ProxyPort = 0 Request.ContentLength = -1 Request.ContentRangeEnd = -1 Request.ContentRangeStart = -1 Request.ContentRangeInstanceLength = -1 Request.Accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' Request.BasicAuthentication = False Request.UserAgent = 'Mozilla/3.0 (compatible; Indy Library)' Request.Ranges.Units = 'bytes' Request.Ranges = <> HTTPOptions = [hoForceEncodeParams] Compressor = IdCompressorZLib1 Left = 16 Top = 8 end object IdCompressorZLib1: TIdCompressorZLib Left = 72 Top = 8 end object IdCompressionIntercept1: TIdCompressionIntercept CompressionLevel = 0 Left = 128 Top = 8 end
Delphi-Quellcode:
function GetPage(aURL, sFile: string): string;
const HTTP_RESPONSE_OK = 200; var Response: TStringStream; fehler: string; begin Result := ''; Response := TStringStream.Create(''); try Form1.IdHTTP1.Get(aURL, Response); if Form1.IdHTTP1.ResponseCode = HTTP_RESPONSE_OK then begin Result := Response.DataString; end else begin fehler := 'ERROR: '+inttostr(Form1.IdHTTP1.ResponseCode)+' '+Form1.IdHTTP1.ResponseText; Response.WriteString(fehler); end; except fehler := 'ERROR: '+inttostr(Form1.IdHTTP1.ResponseCode)+' '+Form1.IdHTTP1.ResponseText; Response.WriteString(fehler); end; Response.SaveToFile(sFile); Response.Free; end; procedure TForm1.FormCreate(Sender: TObject); begin GetPage(URL,'FileToSave.txt'); GetPage(URL,'FileToSave.txt'); end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 08:25 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