Einzelnen Beitrag anzeigen

Delphi.Narium

Registriert seit: 27. Nov 2017
2.431 Beiträge
 
Delphi 7 Professional
 
#15

AW: Hilfe - HTTPS unterschiedliches Verhalten

  Alt 3. Aug 2018, 09:09
ungefähr sowas:
Delphi-Quellcode:
function MyGetUrl(http: tidHTTP; sUrl: string; sl : TStrings; var sMessage: string): Boolean;
begin
  Result := false;
  try
    http.RedirectMaximum := 0; // oder die Anzahl der maximal erwünschten Redirects
    http.HandleRedirects := false; // und hier dann true.
    http.Response.Clear;
    http.Get(sUrl, sl);
    http.Disconnect(True);
    http.IOHandler.InputBuffer.Clear;
    Result := true;
  except
    on e: Exception do begin
      case http.ResponseCode of
        301, 302 : sMessage := http.ResponseText;
      else
        sMessage := AnsiReplaceText(e.Message, #13#10, ' ');
      end;
      // Fehler ggfls. protokollieren:
      PSReg.WriteAppLog(Format('Scriptaufruf : GetSSLMethod(%s)', [sUrl]));
      PSReg.WriteAppLog(Format('Fehlermeldung: %s', [AnsiReplaceText(e.Message, #13#10, ' ')]));
      PSReg.WriteAppLog(Format('SSLMethod : %s', [sMethod]));
      http.Disconnect(True);
      http.IOHandler.InputBuffer.Clear;
    end;
  end;
end;
Minimal:
Delphi-Quellcode:
try
  http.Response.Clear;
  sIrgendeineStringVariabel := http.Get('https://www.delphipraxis.net/dp_recentthreads.php?timeframe=48hr');
  http.Disconnect(True);
  http.IOHandler.InputBuffer.Clear;
except
  on e: Exception do begin
    ShowMessage(e.Exception);
    http.Disconnect(True);
    http.IOHandler.InputBuffer.Clear;
  end;
end;
eventuell auch:
Delphi-Quellcode:
try
  http.Response.Clear;
  try
    sIrgendeineStringVariabel := http.Get('https://www.delphipraxis.net/dp_recentthreads.php?timeframe=48hr');
  except
    ShowMessage(e.Exception);
  end;
finally
  http.Disconnect(True);
  http.IOHandler.InputBuffer.Clear;
end;
  Mit Zitat antworten Zitat