Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Aug : idHTTP.Get and AdjustStreamSize issue

www.cryer.info
Managed Newsgroup Archive

idHTTP.Get and AdjustStreamSize issue

Subject:idHTTP.Get and AdjustStreamSize issue
Posted by:"York" (offi..@onlinebg.info)
Date:Wed, 9 Aug 2006 07:54:45

Hello.

I need your advice on this:

I am using idHTTP.Get(url, mystream) to download a specific file into a file
stream.
This file contains some data following a custom protocol. I do this in a
thread.
Another thread starts parsing the file.
The problem I experience is that if the file is let's say 1024KB and when I
call idHTTP.Get it internally calls a procedure AdjustStreamSize which sets
the size of MyStream to the size of the file. However the file is not
downloaded and the stream contains 0 up to its end.
So my parser thread reads zeros from the file.
I know this sounds more like a non-indy issue but an algorithmic one so I
thought you could give me some advice how to handle this situation.
Here are some more details:
The content of the file contains data blocks. Each block has a 20 byte
header - a record telling what actually follows as well as the size of the
following data. After the header comes the data and then the next header and
next data and so on.
So when IdHttp.Get starts getting the content it fills in the stream with
whatever is comming from the server.
My parser thread starts from the beginning of the file in some time after
the "get" is called and tries to read the first header. It usually succeeds
and after that tries to read the data portion followed by the first header
(determined by the size recorded in the header) However for large data
blocks the parser thread reads 0 because the entire portion of the content
has not been downloaded.
I have no chance to check the stream.size because it is already set to the
size of the original file (AdjustStreamSize)

Any ideas?

Regards

Replies:

www.cryer.info
Managed Newsgroup Archive