function SendPostData(Ahttp: TIdHTTP; const AtoURL: String; const aParams: TStrings): String;
Var
lStream: TMemoryStream;
lParams: TStringStream;
I: Integer;
begin
Result:='';
if not Assigned(aHttp) then
exit;
lStream := TMemoryStream.create;
lParams := TStringStream.create('');
try
AHTTP.Request.CustomHeaders.AddValue('X-Requested-With', 'XMLHttpRequest');
AHTTP.Request.Host := Form1.Edit1.Text;
AHTTP.Request.UserAgent := 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0';
AHTTP.Request.Accept := '*/*';
AHTTP.Request.AcceptLanguage := 'de,en-US;q=0.7,en;q=0.3';
AHTTP.Request.AcceptEncoding := 'gzip, deflate';
AHTTP.Request.Referer := Form1.Edit2.Text;
AHTTP.Request.ContentType := 'application/x-www-form-urlencoded';
AHTTP.Request.CharSet := 'UTF-8';
AHTTP.Request.ContentLength := 31;
AHTTP.Request.Connection := 'keep-alive';
for I:=0 to aParams.Count-1 do
lParams.WriteString(aParams[I] + '&');
try
AHTTP.Post(AtoURL,
lParams,
lStream);
except
on E:
Exception do
showmessage('Fehler bei der Übertragung: ' + E.Message);
end;
SetLength(Result, lStream.Size);
lStream.Position := 0;
lStream.ReadBuffer(Result[1], lStream.Size);
finally
lParams.Free;
lStream.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
xStr : TStringList;
xIdHTTP : TIdHTTP;
begin
xIdHTTP := TIdHTTP.Create(nil);
xStr := TStringList.Create;
try
xIdHTTP.HandleRedirects := True;
xIdHTTP.IOHandler := IdSSLIOHandlerSocketOpenSSL1;
xIdHTTP.CookieManager := IdCookieManager1;
xIdHTTP.Compressor := IdCompressorZLib1;
xIdHTTP.AllowCookies := True;
xStr.Text := Memo2.Text;
Memo1.Text := SendPostData(xIdHTTP, AdvEdit3.Text, xStr);
finally
xStr.Free;
xIdHTTP.Free;
end;
end;