🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #4732

Re: TIdHTTP OnWork

#4732
From: Remy Lebeau (TeamB)
Date: Wed, 22 Dec 2004 09:26
42 lines
2689 bytes
"Ted Tripp" <ttripp@rankexec.com> wrote in message
news:41c90294$1@newsgroups.borland.com...

> I am running into a situation where, when doing a Get on a particular
page(s),
> the data comes in chunks.

That is likely if the content is large.

> In other words the WorkStart event occurs maybe ten times for a
> single page, thus causing the OnWork to occur 10+ times on the
> same page.

OnWork is usually triggered in a loop by Indy reading data streams in
fixed-sized pieces internally.

If you are getting multiple OnWorkBegin events, it is likely that the HTTP
server itself is sending the data in multiple blocks rather than one
continuous stream (the "Transfer-Encoding" header is set to "chunked").
Thus TIdHTTP has to read the data in multiple blocks and then piece them
back together.  Each block would have its own set of
OnWorkBegin/OnWork/OnWorkEnd events being triggered, because TIdHTTP has no
way of knowing ahead of time how much many blocks are being sent or how
large each block is.  The OnWork event will not provide an accurate count,
though, because TIdHTTP will be calling ReadLn() during a chunked transfer.
ReadLn() triggers OnWork as well, so the total reported count will not be
the same as the Size of the data actually being returned to you in the final
response.

> Is this a result of the RecBuf size I set

No.  The triggering of the OnWork events is directly related to how the data
is being transferred, not how large the data is.

> and if so, how do I get an accurate total of data received.

You could query the TIdHTTP.Response.ContentStream.Size property during the
transfer.


Gambit
Technical Details
Message-ID: <41c93d7b$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.multikabel.nl!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <41c89ab7$1@newsgroups.borland.com> <41c8a682$1@newsgroups.borland.com> <41c90294$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,a208acfa73369e15
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <41c89ab7$1@newsgroups.borland.com> <41c8a682$1@newsgroups.borland.com> <41c90294$1@newsgroups.borland.com>
Subject: Re: TIdHTTP OnWork
Date: Wed, 22 Dec 2004 01:26:09 -0800
Lines: 44
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <41c93d7b$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1103707515 68.69.17.41 (22 Dec 2004 01:25:15 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.multikabel.nl!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail