procedure TformMain.serverCommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var url:
string;
responseStream,requestStream:TStringStream;
wdh:integer;
begin
if ARequestInfo.Command='
'
then exit;
client.Request.Method:=ARequestInfo.Command;
client.Request.Host:='
mta.dbtelematik.de';
client.Request.URL:=ARequestInfo.Document;
if ARequestInfo.QueryParams<>'
'
then
client.Request.URL:=client.Request.URL+'
?'+ARequestInfo.QueryParams;
client.Request.UserAgent:=ARequestInfo.UserAgent;
client.Request.Accept:=ARequestInfo.Accept;
client.Request.AcceptCharSet :=ARequestInfo.AcceptCharSet;
client.Request.AcceptEncoding:=ARequestInfo.AcceptEncoding;
client.Request.AcceptLanguage:=ARequestInfo.AcceptLanguage;
client.Request.ContentType:=ARequestInfo.ContentType;
client.Request.Connection:=ARequestInfo.Connection;
url:='
http://'+client.Request.Host+client.Request.URL;
Log('
Command: '+ARequestInfo.Command);
Log('
URL:'+
url);
Log('
Params:'+ARequestInfo.UnparsedParams);
requestStream:=TStringStream.Create('
');
requestStream.CopyFrom(ArequestInfo.PostStream,0);
responseStream:=TStringStream.Create('
');
wdh:=5;
repeat
try
if client.Request.Method='
POST'
then begin
client.Post(
url,requestStream,responseStream);
end;
wdh:=0;
AResponseInfo.ResponseNo := client.ResponseCode;
except
on E: EIDSocketError
do begin
Log('
EIDSocketError#'+IntToStr(e.LastError));
client.Disconnect;
Sleep(2000);
dec(wdh);
if wdh=0
then begin
AResponseInfo.ResponseNo:=404;
AResponseInfo.ResponseText:='
SyncServer: Fehler bei Client-Connection';
end;
end;
end;
until wdh=0;
Log('
Response To Commi:'+IntToStr(AResponseInfo.ResponseNo)+'
'+AResponseInfo.ResponseText);
requestStream.Free;
AResponseInfo.ContentLength:=client.Response.ContentLength;
AResponseInfo.ServerSoftware:= client.Response.Server;
AResponseInfo.Date:= client.Response.Date;
AResponseInfo.LastModified:= client.Response.LastModified;
AResponseInfo.ContentType:=client.Response.ContentType;
AResponseInfo.ContentEncoding:=client.Response.ContentEncoding;
AResponseInfo.ContentLanguage:=client.Response.ContentLanguage;
AResponseInfo.ContentVersion:=client.Response.ContentVersion;
AResponseInfo.ContentText:=responseStream.DataString;
client.Response.ContentStream:=nil;
responseStream.Free;
end;