procedure TDemoForm.HTTPServerCommandGet(AThread: TIdPeerThread;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
client: TIdHTTP;
begin
UILock.Acquire;
try
VLE.Strings.Assign(ARequestInfo.Params);
finally
UILock.Release;
end;
AResponseInfo.ContentStream := TMemoryStream.Create;
client := TIdHTTP.Create(
nil);
with client
do
begin
Request.Assign(ARequestInfo);
HandleRedirects := true;
AllowCookies := true;
CookieManager := TIdCookieManager.Create(client);
end;
if ARequestInfo.Command = '
POST'
then
client.Post(
// 'http://' + ARequestInfo.Host + ARequestInfo.Document,
'
http://localhost/root/test.php',
ARequestInfo.Params,
AResponseInfo.ContentStream
)
else if ARequestInfo.Command = '
GET'
then
client.Get(
'
http://' + ARequestInfo.Host + ARequestInfo.Document,
AResponseInfo.ContentStream
)
else
begin
ShowMessage(ARequestInfo.Command);
Exit;
end;
AResponseInfo.ContentType := client.Response.ContentType;
AResponseInfo.ContentLength := AResponseInfo.ContentStream.Size;
AResponseInfo.ResponseNo := client.ResponseCode;
AResponseInfo.ServerSoftware := client.Response.Server;
AResponseInfo.WriteHeader;
AResponseInfo.WriteContent;
AResponseInfo.ContentStream.Free;
client.Free;
end;