Reputation: 1113
I'm wondering if I can have onCommandGet event where I can redirect the client request to another host/port, get the information I need with TIdHTTP (client) and send it back to the client via AResponseInfo ?
It shoold look like this :
procedure HTTPServerCommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
client : TIdHTTP;
begin
client := TIdHTTP.Create();
try
client.Request := ARequestInfo; // or somehow put the ARequestInfo in the client
... // in here I don't know how to make the GET, POST, HEAD or other
... // (if possible) request to 'some_host:some_port'
AResponseInfo := client.Response; // or somehow put the client Response in AResponseInfo
finally
FreeAndNil(client);
end;
end;
Upvotes: 2
Views: 1099
Reputation: 596176
There is no native solution to do what you are asking for. You will have to implement it manually. Copy the relevant values from ARequestInfo
properties into TIdHTTP.Request
as needed, then call TIdHTTP.Get()
, TIdHTTP.Post()
, etc as needed, and then copy the relevant values from TIdHTTP.Response
into AResponseInfo
as needed.
Upvotes: 2