Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Indy IdHttp, SSL and Proxy in Delphi
I already answered your same question on StackOverflow:

Indy IdHttp, SSL and Proxy in Delphi

I am including my answer below for reference purposes:

Quote:The TIdHTTP.ProxyParams.ProxyServer property expects just a hostname, not a full URL. Change this line:

FIdHTTP.ProxyParams.ProxyServer := '';

To this instead:

FIdHTTP.ProxyParams.ProxyServer := ''


On a side note:

You don't need the following lines, so you should remove them completely:

FIdHTTP.Response.ContentType := 'application/json';
FIdHTTP.Request.CustomHeaders.Values['Authorization'] := 'Basic xxxxxxx==';

TIdHTTP has builtin support for Basic authentication. Simply set the TIdHTTP.Request.Username and TIdHTTP.Request.Password properties as needed, and set the TIdHTTP.Request.BasicAuthorization property to True.

Also, if you want the response data as a string, TIdHTTP.Post() has an overload for that purpose:

zJson := IdHTTP.Post(zURL, zJsonStreamIn);

But either way, putting the call to TIdHTTP.Post() in a try..finally is good for cleanup, but if an HTTP error occurs, your zJson won't receive any data by default. If you need the response body for HTTP errors, you will need to either:
  • catch the resulting EIdHTTPProtocolException and assign its ErrorMessage property to your zJson variable.
  • enable the hoNoProtocolErrorException and hoWantProtocolErrorContent flags in the TIdHTTP.HTTPOptions property, then zJson will receive both success and failure response bodies equally.


Messages In This Thread
Indy IdHttp, SSL and Proxy in Delphi - by varlau - 02-28-2022, 03:47 PM
RE: Indy IdHttp, SSL and Proxy in Delphi - by rlebeau - 02-28-2022, 05:50 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)