Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 May : TIdTCPClient, TIdIOHandler and a Headache

www.cryer.info
Managed Newsgroup Archive

TIdTCPClient, TIdIOHandler and a Headache

Subject:TIdTCPClient, TIdIOHandler and a Headache
Posted by:"Lloyd Kinsella" (lloydkinsel..@gmail.com)
Date:28 May 2006 21:19:16

I'm writing a small HTTP proxy for something I'm doing and I'm
struggling. The problem is, TIdHTTPProxy uses ReadStream/Write{Stream}
in order to do the transferal, which is fine for small files, but
imagine this for files in the MB, GB range, the proxy server would
first have to download the entire file, and then upload.

What I've been trying is to read a buffer of bytes from the remote HTTP
server connection and write them off to the HTTP client but I'm having
trouble with this part, how can I read continually in blocks from
server to client?

I tried:

while True do
  begin
    SetLength(Buffer,0);
    Client.IOHandler.ReadBytes(Buffer,MaxBufSize);
      if Length(Buffer) = 0 then Break;
    ASender.Context.Connection.IOHandler.Write(Buffer);
  end;

However this doesn't seem to work!

Any ideas and suggestions?

- Lloyd
--

Replies:

www.cryer.info
Managed Newsgroup Archive