Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 May : Re: TIdTCPClient, TIdIOHandler and a Headache
| Subject: | Re: TIdTCPClient, TIdIOHandler and a Headache |
| Posted by: | "Lloyd Kinsella" (lloydkinsel..@gmail.com) |
| Date: | 29 May 2006 19:39:26 |
You misunderstood my english, I wasn't saying it DID support it, I was
saying even if it did/did not, I've not using that component, which you
assumed I was earlier in the thread as I hadn't clarified I was using
TIdCmdTCPServer.
I'll give your ideas a bash and see how it turns out, thanks.
- Lloyd
Remy Lebeau (TeamB) wrote:
>
> "Lloyd Kinsella" <lloydkinsella@gmail.com> wrote in message
> news:447b665f@newsgroups.borland.com...
>
> > I am using my own, I'm using TIdCmdTCPServer like the proxy
> > component does, I was just stating how TIdHTTPProxy does it.
> > My issue is HOW to implement the send-as-it-captures
>
> You need to use ReadBytes/Write(Bytes) instead of
> ReadStream/Write(Stream).
>
> > as the code I gave doesn't work
>
> You did not show WHERE that code is being called from. You are also
> doing blocking reads on MaxBufSize packets, which makes the code
> block if smaller packets are received. You should be taking into
> account the actual size of the packets being received instead. For
> example:
>
> var
> DataSize: Int64;
> begin
> // send request to target server ...
> // read headers ...
> If (The Data Size Is Specified) then
> begin
> DataSize := (The Specified Data Size Here);
> while DataSize > 0 do
> begin
> SetLength(Buffer, Max(DataSize, MaxBufSize));
> Client.IOHandler.ReadBytes(Buffer, Length(Buffer),
> False);
> ASender.Context.Connection.IOHandler.Write(Buffer);
> Dec(DataSize, Length(Buffer)); end;
> end else
> begin
> while Client.Connected do
> begin
> if Client.IOHandler.InputBuffer.Size < MaxBufSize then
> Client.IOHandler.CheckForDataOnSource(1000);
> if Client.IOHandler.InputBuffer.Size > 0 then
> begin
> DataSize := Max(Client.IOHandler.InputBuffer.Size,
> MaxBufSize);
> SetLength(Buffer, DataSize);
>
> Client.IOHandler.InputBuffer.ExtractToBytes(Buffer, DataSize, False);
>
> ASender.Context.Connection.IOHandler.Write(Buffer);
> end; end;
> end;
> end;
>
>
> > it's not that TIdHTTPProxy doesn't support it
>
> TIdHTTPProxyServer does not support it at all, period. It is
> strictly a capture-all-and-then-send component, which is not what you
> are asking for.
>
>
> Gambit
--
none