> The error I get is it sometimes shuts down before all the
> data is actually pumped.
Your code fragment is difficult to understand. There are to much noise 
because of features in your program. You'd better build a simplified code.

Anyway, if this can help you, I remind you that OnDataSrnt event doesn't 
mean the data has been sent out to the remote site but that TWSocket has 
emptied his buffer to winsock own buffer. Winsock has still to send data and 
for for ack. There is no way to know that winsock has completely sent 
everything out and received corresponding ACK, except by closing the 
connection using linger (this will BLOCK the close operation).

--
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
http://www.overbyte.be



----- Original Message ----- 
From: "Fastream Technologies" <[EMAIL PROTECTED]>
To: "ICS support mailing" <twsocket@elists.org>
Sent: Friday, September 01, 2006 4:14 PM
Subject: [twsocket] Need help with HTTP


> Hello,
>
> In the OnDocData of THttpCli descendent, I pause the THTtpCli and
> Send(Buffer, Len) to the THttpConnection (this is a proxy server). The
> problem is at ConnectionDataAvailable of THttpConnection, I cannot be sure
> that all the data is sent or is it complete because sometimes packets are
> merged and I cannot be sure how much of the downloaded data is actually 
> sent
> to the client. Here is the code:
>
> void __fastcall httpServerClientClass::HTTPClientDocData(TObject *Sender,
>
> Pointer Buffer,
>
> int Len)
>
> {
>
> if(compressionType <= 0 && !absURLTranslation && (!noContentLength ||
> transferEncodingChunked))
>
> {
>
> HTTPClient->PauseCS(false);
>
> sendDataToRequesterClient(Buffer, Len);
>
> }
>
> else
>
> {
>
> aggregateDataForGZipSending(Buffer, Len);
>
> }
>
> }
>
> //---------------------------------------------------------------------------
>
> void __fastcall httpServerClientClass::sendDataToRequesterClient(Pointer
> buffer, int len)
>
> {
>
> if(cacheType == cacheJustAdd)
>
> {
>
> lockCriticalSection(objectCacheCS);
>
> objectCache->Position = cachePosition;
>
> objectCache->Write(buffer, len);
>
> cachePosition = objectCache->Position;
>
> releaseCriticalSection(objectCacheCS);
>
> }
>
> int Count = 0;
>
> if(transferEncodingChunked && State == wsConnected && lastCommand !=
> httpCommandHEAD && protocolStatus[1] != '3')
>
> {
>
> Count = SendStr("\r\n" + String(IntToHex(len, 1)) + "\r\n");
>
> bytesReceived += Count;
>
> }
>
> if(State == wsConnected)
>
> {
>
> Count += Send(buffer, len);
>
> DataSent += Count; // count data which is sent by the last buffer
>
> if(transferEncodingChunked && DataSent >= DataToBeSent)
>
> {
>
> if(protocolStatus[1] != '3' && lastCommand != httpCommandHEAD)
>
> {
>
> SendStr("\r\n0\r\n\r\n");
>
> bytesReceived += 7;
>
> }
>
> }
>
> countTransferredPer100ms(Count);
>
> setLastActionTime();
>
> }
>
> }
>
> //---------------------------------------------------------------------------
>
> void __fastcall httpServerClientClass::HTTPClientDocEnd(TObject *Sender)
>
> {
>
> if(HTTPClient)
>
> HTTPClient->setState(httpReady);
>
> if(noContentLength || transferEncodingChunked)
>
> if(cacheType == cacheJustAdd)
>
> cache->setActualFileSize(cacheURL);
>
> if(compressionType > 0 || absURLTranslation || (noContentLength &&
> !transferEncodingChunked))
>
> SendDocumentWGZip();
>
> else
>
> {
>
> if(transferEncodingChunked)
>
> chunkedTransferEnded = true;
>
> }
>
> }
>
> //---------------------------------------------------------------------------
>
>
>
> void __fastcall
> httpServerClientClass::ConnectionDataSentCleartextTunnel(TObject *Sender,
> WORD Error)
>
> {
>
> ++bytesSent;
>
> if(
>
> (
>
> (!transferEncodingChunked && DataSent >= DataToBeSent && DataPrevSent ==
> DataSent)
>
> ||
>
> (transferEncodingChunked && chunkedTransferEnded)
>
> )
>
> ||
>
> Error
>
> ||
>
> (lastCommand == httpCommandHEAD || protocolStatus[1] == '3')
>
> )
>
> {
>
> objectPosition = DataSent;
>
> socketError = Error;
>
> endOfResponse();
>
> if(!FKeepAlive || Error)
>
> Shutdown(1);
>
> return;
>
> }
>
> if(HTTPClient)
>
> HTTPClient->ResumeCSIfNotPausedByThrottler();
>
> }
>
>
>
> The error I get is it sometimes shuts down before all the data is actually
> pumped.
>
> Hope you can help.
>
> Best Regards,
>
> SZ
>
> -- 
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://www.elists.org/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be 

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to