I have a simple mobile application written in Delphi XE8 that allows the user to take a picture and then send the picture to a server using Indy TCPClient/TCP Server.
I have scoured the forums and found numerous examples to send the data in a variety of ways. Every method I try results in an access violation or corrupt data on the server side.
My ultimate goal is to send a record containing a unique identifier, description and a picture(bitmap) from the client to the server.
But I'm starting out be trying to simply send a record with some text from a windows client to the server. I will then try to implement the solution into my mobile app.
type
TSendRec = record
// SONo: string;
Text: string;
// Bitmap: TBitMap;
end
I have tried the following 3 methods as per the code below:
Send Using a Stream
Send using RawToBytes and TIDBytes.
Send a line of text using Writeln and Readln
When I try to send using a stream I get the following access violation:
Project memorystream_server.exe raised the exception class $C0000005 with message 'access violation at 0x00409e46: write of address 0x0065d1bc
The error occurs when I try to access the value of MiRec.Text on the server side.
Memo1.Lines.Add(MiRec.Text);
So I assume the read of the MIRec is failing for some reason:
When I send using RawToBytes, no error message occurs but the value of MIRec.Text is garbage.
When I just send a line of text using WriteLn, the server receives and displays the data correctly and no access violation occurs.
I tried to follow examples that I have found from other posts on this issue. I would greatly appreciate any insight into what I am doing wrong.
Following are my client and server side code snippets:
Client
procedure TfrmMemoryStreamClient.btnSendClick2(Sender: TObject);
var
Buffer: TIdBytes;
MIRec: TSendRec;
msRecInfo: TMemoryStream;
msRecInfo2: TIdMemoryBufferStream;
begin
IdTCPClient1.Connect;
MIRec.Text := 'Hello World';
if rbSendStream.Checked then
begin
msRecInfo := TMemoryStream.Create;
try
msRecInfo.Write(MIRec, SizeOf(MIRec));
IdTCPClient1.IOHandler.Write(msRecInfo, 0, False);
finally
msRecInfo.Free;
end;
{
msRecInfo2 := TIdMemoryBufferStream.Create(#MIRec, SizeOf(TSendRec));
try
IdTCPClient1.IOHandler.Write(msRecInfo2);
finally
msRecInfo.Free;
end;
}
end
else
if rbSendBytes.Checked then
begin
Buffer := RawToBytes(MIRec, SizeOf(MIRec));
IdTCPClient1.IOHandler.Write(Buffer);
end
else
if rbWriteLn.Checked then
begin
IdTCPClient1.Socket.WriteLn(Edit1.Text);
end;
IdTCPClient1.DisConnect;
end;
Server
procedure TStreamServerForm.IdTCPServer1Execute(AContext: TIdContext);
var sName: String;
MIRec: TSendRec;
Buffer: TIdBytes;
msRecInfo: TMemoryStream;
begin
if not chkReceiveText.Checked then
begin
try
if chkReadBytes.Checked then
begin
AContext.Connection.IOHandler.ReadBytes(Buffer, SizeOf(MIRec));
BytesToRaw(Buffer, MIRec, SizeOf(MIRec));
Memo1.Lines.Add(MiRec.Text);
end
else
begin
msRecInfo := TMemoryStream.Create;
try
// does not read the stream size, just the stream data
AContext.Connection.IOHandler.ReadStream(msRecInfo, SizeOf(MIRec), False);
msRecInfo.Position := 0;
msRecInfo.Read(MIRec, SizeOf(MIRec));
Memo1.Lines.Add(MiRec.Text);
finally
msRecInfo.Free;
end;
{
AContext.Connection.IOHandler.ReadStream(msRecInfo, -1, False);
msRecInfo.Position := 0;
msRecInfo.Read(MIRec, SizeOf(MIRec));
Memo1.Lines.Add(MiRec.Text);
}
end;
Memo1.Lines.Add('read File');
except
Memo1.Lines.Add('error in read File');
end;
end
else
begin
sName := AContext.Connection.Socket.ReadLn;
Memo1.Lines.Add(sName);
end;
AContext.Connection.Disconnect;
end;
TIdTCPServer is a multithreaded component. Its OnConnect, OnDisconnect, and OnExecute events are triggered in the context of a worker thread. As such, you MUST synchronize with the main UI thread when accessing UI controls, like your Memo.
Also, String is a compiler-managed data type, and TBitmap is an object. Both store their data elsewhere in memory, so you cannot write a record containing such fields as-is. You would be writing only the value of their data pointers, not writing the actual data being pointed at. You need to serialize your record into a transmittable format on the sending side, and then deserialize it on the receiving side. That means handling the record fields individually.
Try something more like this:
type
TSendRec = record
SONo: string;
Text: string;
Bitmap: TBitMap;
end;
Client
procedure TfrmMemoryStreamClient.btnSendClick2(Sender: TObject);
var
MIRec: TSendRec;
ms: TMemoryStream;
begin
MIRec.SONo := ...;
MIRec.Text := 'Hello World';
MIRec.Bitmap := TBitmap.Create;
...
try
IdTCPClient1.Connect;
try
IdTCPClient1.IOHandler.WriteLn(MIRec.SONo);
IdTCPClient1.IOHandler.WriteLn(MIRec.Text);
ms := TMemoryStream.Create;
try
MIRec.Bitmap.SaveToStream(ms);
IdTCPClient1.IOHandler.LargeStream := True;
IdTCPClient1.IOHandler.Write(ms, 0, True);
finally
ms.Free;
end;
finally
IdTCPClient1.Disconnect;
end;
finally
MIRec.Bitmap.Free;
end;
end;
Server
procedure TStreamServerForm.IdTCPServer1Execute(AContext: TIdContext);
var
MIRec: TSendRec;
ms: TMemoryStream;
begin
MIRec.SONo := AContext.Connection.IOHandler.ReadLn;
MIRec.Text := AContext.Connection.IOHandler.ReadLn;
MIRec.Bitmap := TBitmap.Create;
try
ms := TMemoryStream.Create;
try
AContext.Connection.IOHandler.LargeStream := True;
AContext.Connection.IOHandler.ReadStream(ms, -1, False);
ms.Position := 0;
MIRec.Bitmap.LoadFromStream(ms);
finally
ms.Free;
end;
TThread.Synchronize(nil,
procedure
begin
Memo1.Lines.Add(MIRec.SONo);
Memo1.Lines.Add(MIRec.Text);
// display MIRec.Bitmap as needed...
end;
end;
finally
MIRec.Bitmap.Free;
end;
end;
Alternatively:
Client
procedure TfrmMemoryStreamClient.btnSendClick2(Sender: TObject);
var
MIRec: TSendRec;
ms: TMemoryStream;
procedure SendString(const S: String);
var
Buf: TIdBytes;
begin
Buf := IndyTextEncoding_UTF8.GetBytes(S);
IdTCPClient1.IOHandler.Write(Int32(Length(Buf)));
IdTCPClient1.IOHandler.Write(Buf);
end;
begin
MIRec.SONo := ...;
MIRec.Text := 'Hello World';
MIRec.Bitmap := TBitmap.Create;
...
try
IdTCPClient1.Connect;
try
SendString(MIRec.SONo);
SendString(MIRec.Text);
ms := TMemoryStream.Create;
try
MIRec.Bitmap.SaveToStream(ms);
IdTCPClient1.IOHandler.LargeStream := True;
IdTCPClient1.IOHandler.Write(ms, 0, True);
finally
ms.Free;
end;
finally
IdTCPClient1.Disconnect;
end;
finally
MIRec.Bitmap.Free;
end;
end;
Server
procedure TStreamServerForm.IdTCPServer1Execute(AContext: TIdContext);
var
MIRec: TSendRec;
ms: TMemoryStream;
function RecvString: String;
begin
Result := AContext.Connection.IOHandler.ReadString(
AContext.Connection.IOHandler.ReadInt32,
IndyTextEncoding_UTF8);
end;
begin
MIRec.SONo := RecvString;
MIRec.Text := RecvString;
MIRec.Bitmap := TBitmap.Create;
try
ms := TMemoryStream.Create;
try
AContext.Connection.IOHandler.ReadStream(ms, -1, False);
ms.Position := 0;
MIRec.Bitmap.LoadFromStream(ms);
finally
ms.Free;
end;
TThread.Synchronize(nil,
procedure
begin
Memo1.Lines.Add(MIRec.SONo);
Memo1.Lines.Add(MIRec.Text);
// display MIRec.Bitmap as needed...
end;
end;
finally
MIRec.Bitmap.Free;
end;
end;
Related
I am trying to stream a TClientDataSet using Datasnap in Delphi XE6. However, I keep getting a "Missing Data Provider or Data Packet" error on the client side code.
//Client
procedure TForm2.Button1Click(Sender: TObject);
var
CDS: TClientDataSet;
S: TStream;
begin
CDS := TClientDataSet.Create(nil);
try
S:= ClientModule1.ServerMethods1Client.getCDSData;
S.Seek(0,soFromBeginning);
S.Position:= 0;
CDS.LoadFromStream(S);
CDS.Open; // Missing Data Provider or Data Packet
finally
CDS.Free;
end;
end;
//Server
function TServerMethods1.getCDSData: TStream;
var
Writer: TBinaryWriter;
CDS: TClientDataSet;
I: Integer;
begin
result := TMemoryStream.Create;
CDS := TClientDataSet.Create(nil);
with CDS.FieldDefs do
begin
Clear;
Add('First', ftString, 20);
Add('Last', ftString, 25);
end;
CDS.CreateDataSet;
CDS.Open;
CDS.AppendRecord(['John', 'Smith']);
CDS.AppendRecord(['Jane', 'Doe']);
try
CDS.SaveToStream(result);
finally
CDS.Free;
end;
end;
I also tried Streaming it as XML instead of Binary
CDS.SaveToStream(result, dfXML);
get the same error
"Missing Data Provider or Data Packet"
ANSWER:
CDS.SaveToStream(result);
Result.Position := 0; //need this in server method "getCDSData"
CDS.SaveToStream(result);
Result.Position := 0;
I try to send a string from a tidtcpserver to a tidtcpclient in Delphi, but when i send a string the client receives nothing. I don't get any errors. I am using tstringstream because i want to send a base64 string(writeln/readln can't send/receive that much text)
This is the send code in idtcpserver1:
procedure TForm1.sendtext(index:integer; txt:string);
var
StrStream:tStream;
List: TList;
AContext: TIdContext;
begin
txt := trim(txt);
strstream := TMemoryStream.Create;
strstream.Write(PAnsiChar(txt)^, Length(txt));
strstream.Position := 0;
List := idTcpServer1.Contexts.LockList;
AContext := TIdContext(List[index]);
AContext.Connection.IOHandler.write(StrStream);
idTcpServer1.Contexts.UnLockList;
end;
This is the read code in idtcpclient1
procedure TIndyClient.Execute;
var
StrStream:tStringStream;
receivedtext:string;
begin
StrStream := tstringstream.Create;
form1.IdTCPClient1.IOHandler.readstream(StrStream);
receivedtext := strstream.DataString;
if receivedtext = '' = false then
begin
showmessage(receivedtext);
end;
end;
Does anyone know what i am doing wrong?
You are making a very common newbie mistake of mismatching the IOHandler.Write(TStream) and IOHandler.ReadStream() calls. By default, ReadStream() expects the stream data to be preceded by the stream size, but Write(TStream) does not send the stream size by default.
Try this instead:
procedure TForm1.sendtext(index: integer; const txt: string);
var
StrStream: TMemoryStream;
List: TList;
AContext: TIdContext;
begin
strStream := TMemoryStream.Create;
try
WriteStringToStream(StrStream, Trim(txt), enUTF8);
List := idTcpServer1.Contexts.LockList;
try
AContext := TIdContext(List[index]);
AContext.Connection.IOHandler.Write(StrStream, 0, True);
finally
idTcpServer1.Contexts.UnlockList;
end;
finally
StrStream.Free;
end;
end;
procedure TIndyClient.Execute;
var
StrStream: TMemoryStream;
receivedtext: string;
begin
StrStream := TMemoryStream.Create;
try
Form1.IdTCPClient1.IOHandler.ReadStream(StrStream, -1, False);
StrStream.Position := 0;
receivedtext := ReadStringFromStream(StrStream, enUTF8);
finally
StrStream.Free;
end;
if receivedtext <> '' then
begin
// ShowMessage() is not thread-safe...
MessageBox(0, PChar(receivedtext), PChar(Application.Title), MB_OK);
end;
end;
Alternatively, because the stream size is now being sent, the receiving code can use ReadString() instead of ReadStream():
procedure TIndyClient.Execute;
var
receivedtext: string;
begin
with Form1.IdTCPClient1.IOHandler do
begin
// you can alternatively set the IOHandler.DefStringEncoding
// instead of passing the encoding as a parameter...
receivedtext := ReadString(ReadLongInt, enUTF8);
end;
if receivedtext <> '' then
begin
// ShowMessage() is not thread-safe...
MessageBox(0, PChar(receivedtext), PChar(Application.Title), MB_OK);
end;
end;
BTW, WriteLn()/ReadLn() do not have any length restrictions, they can handle big strings as long as there is available memory (and the text being sent does not have any line breaks in it). You are probably being confused by ReadLn() being subject to the IOHandler.MaxLineLength, which is set to 16K characters by default, but you can bypass that:
procedure TForm1.sendtext(index: integer; const txt: string);
va
List: TList;
AContext: TIdContext;
begin
List := idTcpServer1.Contexts.LockList;
try
AContext := TIdContext(List[index]);
// you can alternatively set the IOHandler.DefStringEncoding
// instead of passing the encoding as a parameter...
AContext.Connection.IOHandler.WriteLn(Trim(txt), enUTF8);
finally
idTcpServer1.Contexts.UnlockList;
end;
end;
procedure TIndyClient.Execute;
var
receivedtext: string;
begin
// you can alternatively set the IOHandler.DefStringEncoding
// and IOHandler.MaxLineLength instead of passing them as parameters...
receivedtext := Form1.IdTCPClient1.IOHandler.ReadLn(LF, -1, MaxInt, enUTF8);
if receivedtext <> '' then
begin
// ShowMessage() is not thread-safe...
MessageBox(0, PChar(receivedtext), PChar(Application.Title), MB_OK);
end;
end;
i'm using delphi xe4 with indy10 component and i want to send an image from an Tidudpclient to Tidudpserver. I already done this operation with tcp component,but the same code didn't work with udp. how i can do this?
Thanks in advance!
Timage(client)--->streamUDP-->Timage(server)
CLIENT SIDE----------------------------------------------- SEND IMAGE
var
pic: tbitmap;
Strm : TMemoryStream;
img2:Timage;
buffer:TIdBytes;
begin
try
img2:=Timage.Create(nil);
pic:=Tbitmap.Create;
Takekpic(pic);
BMPtoJPG(pic,img2);
Strm := TMemoryStream.Create;
img2.Picture.bitmap.SaveToStream(strm);
Strm.Position:=0;
ReadTIdBytesFromStream(Strm,buffer,SizeOf(Strm),0);
IdTrivialFTPServer1.SendBuffer('192.168.17.128',1234,buffer);
finally
strm.Free;
end;
end;
SERVER SIDE---------------------------------------------------- READ IMAGE
procedure TForm6.IdTrivialFTP1UDPRead(AThread: TIdUDPListenerThread;
const AData: TIdBytes; ABinding: TIdSocketHandle);
var
Strm : TMemoryStream;
Jpg: TJpegImage;
begin
Strm := TMemoryStream.Create;
try
WriteTIdBytesToStream(Strm,AData,SizeOf(AData),0);
strm.Position:=0;
Jpg := TJpegImage.Create;
jpg.LoadFromStream(Strm); <---- error while reading (JPEG Error #53)
img1.Picture.assign(jpg);
finally
strm.Free;
Jpg.Free;
end;
end;
what can be wrong in this code?
TIdUDPClient and TIdUDPServer do not support sending/receiving TStream data. You can save your image data into a TStream, but you will have to send/receive it using TIdBytes chunks.
Alternatively, use TIdTrivialFTP and TIdTrivialFTPServer instead, which implement TFTP, a UDP-based file transfer protocol. They operate using TStream objects
Update: for example:
Client:
var
bmp: TBitmap;
jpg: TJPEGImage;
Strm : TMemoryStream;
begin
Strm := TMemoryStream.Create;
try
jpg := TJPEGImage.Create;
try
bmp := TBitmap.Create;
try
Takekpic(bmp);
jpg.Assign(bmp);
finally
bmp.Free;
end;
jpg.SaveToStream(Strm);
finally
jpg.Free;
end;
Strm.Position := 0;
{
These can be assigned ahead of time...
IdTrivialFTP1.Host := '192.168.17.128';
IdTrivialFTP1.Port := 1234;
}
IdTrivialFTP1.Put(Strm, 'image.jpg');
finally
Strm.Free;
end;
end;
Server:
procedure TForm6.IdTrivialFTPServer1WriteFile(Sender: TObject; var FileName: String; const PeerInfo: TPeerInfo; var GrantAccess: Boolean; var AStream: TStream; var FreeStreamOnComplete: Boolean) of object;
begin
if FileName = 'image.jpg' then
begin
GrantAccess := True;
AStream := TMemoryStream.Create;
FreeStreamOnComplete := True;
end else
GrantAccess := False;
end;
{
If you set TIdTrivialFTPServer.ThreadedEvent to False, this event handler
runs in the context of the main thread, so the UI can be accessed safely.
If you set IdTrivialFTPServer.ThreadedEvent to True, this event handler
runs in the context of a worker thread, so you will have to manually
synchronize with the main thread when updating the UI...
}
procedure TForm6.IdTrivialFTPServer1TransferComplete(Sender: TObject; const Success: Boolean; const PeerInfo: TPeerInfo; var AStream: TStream; const WriteOperation: Boolean);
var
jpg: TJPEGImage;
begin
if WriteOperation and Success then
begin
jpg := TJPEGImage.Create;
try
AStream.Position := 0;
jpg.LoadFromStream(AStream);
img1.Picture.Assign(jpg);
finally
jpg.Free;
end;
end;
end;
I need help in understanding how to transfer a record through Indy TCP Server/Client. I have 2 programs, in I put client and in another server.
On client on a button I put connect : Client is TIdTCPClient
Client.Connect();
And at server side I am adding a line to memo that client is connected , on ServerConnect event
Protocol.Lines.Add(TimeToStr(Time)+' connected ');
To send data from client I have a record, which I want to send :
Tmyrecord = record
IPStr: string[15];
end;
And I have a send button there :
procedure Tform1.ButtonSendClick(Sender: TObject);
var
MIRec: Tmyrecord;
msRecInfo: TMemoryStream;
begin
MIRec.IPStr := '172.0.0.1';
msRecInfo := TMemoryStream.Create;
msRecInfo.Write(MIRec, SizeOf(MIRec));
msRecInfo.Position := 0;
Client.IOHandler.Write(msRecInfo);
end;
At server side onexecute I have the following code , I have same tmyrecord declared at server side too :
procedure TServerFrmMain.ServerExecute(AContext: TIdContext);
var
MIRec: Tmyrecord;
msRecInfo: TMemoryStream;
begin
if AContext.Connection.Connected then
begin
AContext.Connection.IOHandler.CheckForDataOnSource(10);
if not AContext.Connection.IOHandler.InputBufferIsEmpty then
begin
msRecInfo:= TMemoryStream.Create;
AContext.Connection.IOHandler.ReadStream(msRecInfo);
msRecInfo.Read(MIRec, sizeOf(msRecInfo));
ShowMessage(MIRec.IPStr);
end;
end;
end
I dont know why it is not working, why I cant show IP adress which I wrote from client side.
I want to read a record (msRecInfo) on server side which I am sending from client side. I want to access my record elements, in this case I want to read IPSTR element of my record. When I press send button from a client side, application hangs, server part.
Thanks a lot in advance
You are making a classic newbie mistake - you are expecting the default behaviors of the TIdIOHandler.Write(TStream) and TIdIOHandler.ReadStream() methods to match each other, but they actually do not.
The default parameter values of TIdIOHandler.ReadStream() tell it to expect an Integer or Int64 (depending on the value of the TIdIOHandler.LargeStream property) to preceed the stream data to specify the length of the data.
However, the default parameter values of TIdIOHandler.Write(TStream) do not tell it to send any such Integer/Int64 value. Thus, your use of TIdIOHandler.ReadStream() reads the first few bytes of the record and interprets them as an Integer/Int64 (which is 926036233 given the string value you are sending), and then waits for that many bytes to arrive, which never will so TIdIOHandler.ReadStream() does not exit (unless you set the TIdIOHandler.ReadTimeout property to a non-infinite value).
There are also some other minor bugs/typos in your code that uses the TMemoryStream objects outside of Indy.
Try this instead:
procedure Tform1.ButtonSendClick(Sender: TObject);
var
MIRec: Tmyrecord;
msRecInfo: TMemoryStream;
begin
MIRec.IPStr := '172.0.0.1';
msRecInfo := TMemoryStream.Create;
try
msRecInfo.Write(MIRec, SizeOf(MIRec));
// writes the stream size then writes the stream data
Client.IOHandler.Write(msRecInfo, 0, True);
finally
msRecInfo.Free;
end;
end;
procedure TServerFrmMain.ServerExecute(AContext: TIdContext);
var
MIRec: Tmyrecord;
msRecInfo: TMemoryStream;
begin
msRecInfo := TMemoryStream.Create;
try
// reads the stream size then reads the stream data
AContext.Connection.IOHandler.ReadStream(msRecInfo, -1, False);
msRecInfo.Position := 0;
msRecInfo.Read(MIRec, SizeOf(MIRec));
...
finally
msRecInfo.Free;
end;
end;
Or this:
procedure Tform1.ButtonSendClick(Sender: TObject);
var
MIRec: Tmyrecord;
msRecInfo: TMemoryStream;
begin
MIRec.IPStr := '172.0.0.1';
msRecInfo := TMemoryStream.Create;
try
msRecInfo.Write(MIRec, SizeOf(MIRec));
// does not write the stream size, just the stream data
Client.IOHandler.Write(msRecInfo, 0, False);
finally
msRecInfo.Free;
end;
end;
procedure TServerFrmMain.ServerExecute(AContext: TIdContext);
var
MIRec: Tmyrecord;
msRecInfo: TMemoryStream;
begin
msRecInfo := TMemoryStream.Create;
try
// does not read the stream size, just the stream data
AContext.Connection.IOHandler.ReadStream(msRecInfo, SizeOf(MIRec), False);
msRecInfo.Position := 0;
msRecInfo.Read(MIRec, SizeOf(MIRec));
...
finally
msRecInfo.Free;
end;
end;
Alternatively, you can send the record using TIdBytes instead of TStream:
procedure Tform1.ButtonSendClick(Sender: TObject);
var
MIRec: Tmyrecord;
Buffer: TIdBytes;
begin
MIRec.IPStr := '172.0.0.1';
Buffer := RawToBytes(MIRec, SizeOf(MIRec));
Client.IOHandler.Write(Buffer);
end;
procedure TServerFrmMain.ServerExecute(AContext: TIdContext);
var
MIRec: Tmyrecord;
Buffer: TIdBytes;
begin
AContext.Connection.IOHandler.ReadBytes(Buffer, SizeOf(MIRec));
BytesToRaw(Buffer, MIRec, SizeOf(MIRec));
...
end;
i want to post data to the following url:
http://mehratin.heroku.com/personals/new
i write the following code but has problem:
procedure TForm1.Button3Click(Sender: TObject);
var
aStream: TMemoryStream;
Params: TStringList;
begin
aStream := TMemoryStream.Create;
Params := TStringList.Create;
try
with IdHTTP1 do
begin
Params.Add('fname=123');
Params.Add('lname=123');
Request.ContentType := 'application/x-www-form-urlencoded';
try
Response.KeepAlive := False;
Post('http://localhost:3000/personals/new', Params);
except
on E: Exception do
showmessage('Error encountered during POST: ' + E.Message);
end;
end;
how can i post data by TIDHtttp.post method in delphi 2010?
First things first, you'd need to read the http response code (it would have been useful to include that in your question).
In the absence of that I've used the Indy http object before as shown below. I included the parameters in my URL though. To troubleshoot, try running this with an http.Get to ensure the port is open, and you can actually connect to the server. Here's my example for completenes:
// parameters
params := format('export=1&format=%s&file=%s', [_exportType, destination]);
// First setup the http object
procedure TCrystalReportFrame.SetupHttpObject();
begin
try
IDHTTP1.HandleRedirects := TRUE;
IDHTTP1.AllowCookies := true;
IDHTTP1.Request.CacheControl := 'no-cache';
IdHTTP1.ReadTimeout := 60000;
_basePath:= GetBaseUrl;
except
on E: Exception do
begin
Global.LogError(E, 'SetupHttpObject');
end;
end;
end;
// Then have an onwork event
procedure TCrystalReportFrame.HttpWork(ASender: TObject; AWorkMode: TWorkMode; AWorkCount: Int64);
var
Http: TIdHTTP;
ContentLength: Int64;
Percent: Integer;
begin
Http := TIdHTTP(ASender);
ContentLength := Http.Response.ContentLength;
end;
// The actual process
procedure TCrystalReportFrame.ProcessHttpRequest(const parameters: string);
var
url : string;
begin
try
try
SetupHttpObject;
IdHTTP1.OnWork:= HttpWork;
url := format('%s&%s', [_basePath, parameters]);
url := IdHTTP1.Post(url);
except
on E: Exception do
begin
Global.LogError(E, 'ProcessHttpRequest');
end;
end;
finally
try
IdHTTP1.Disconnect;
except
begin
end;
end;
end;
end;