Re: [twsocket] Need help with HTTP/1.1 digest auth for forward proxy
Fastream Technologies wrote: headerHead += Proxy-Authenticate: Digest + // I only changed this line from rproxy to forward proxy GenerateDigestChallenge() + , domain=\ + prefix + FAuthRealm + : + serverPort + \ + , uri=\ + URI + \ + //, algorithm=\MD5\ + staleString + \r\n; This obviously is your own implementation, current ICS uses : function AuthDigestGenerateChallenge( DigestMethod: TAuthDigestMethod; Secret: TULargeInteger; const Realm, Domain : String; Stale: Boolean; var Nonce, Opaque: String): String; procedure THttpConnection.Answer401; [..] Header := Header + 'WWW-Authenticate: Digest ' + AuthDigestGenerateChallenge( FServer.FAuthDigestMethod, FServer.FAuthDigestServerSecret, FAuthRealm, '', FAuthDigestStale, FAuthDigestServerNonce, FAuthDigestServerOpaque) + #13#10; -- Arno Garrels -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Need help with HTTP/1.1 digest auth for forward proxy
Hi Arno, Ok, let me explain: due to stupid BCB linker errors,I had to place the function below in a pascal unit for calling the function you said: function THttpMTConnection.GenerateDigestChallenge : String; begin Result := AuthDigestGenerateChallenge( FServer.FAuthDigestMethod, FServer.FAuthDigestServerSecret, FAuthRealm, '', FAuthDigestStale, FAuthDigestServerNonce, FAuthDigestServerOpaque); end; And it still does not work. Isn't there anybody with proxy authentication experience? I had basic and NTLM and HTML working fine--only digest left... Regards, SZ On Mon, Sep 21, 2009 at 9:38 AM, Arno Garrels arno.garr...@gmx.de wrote: Fastream Technologies wrote: headerHead += Proxy-Authenticate: Digest + // I only changed this line from rproxy to forward proxy GenerateDigestChallenge() + , domain=\ + prefix + FAuthRealm + : + serverPort + \ + , uri=\ + URI + \ + //, algorithm=\MD5\ + staleString + \r\n; This obviously is your own implementation, current ICS uses : function AuthDigestGenerateChallenge( DigestMethod: TAuthDigestMethod; Secret: TULargeInteger; const Realm, Domain : String; Stale: Boolean; var Nonce, Opaque: String): String; procedure THttpConnection.Answer401; [..] Header := Header + 'WWW-Authenticate: Digest ' + AuthDigestGenerateChallenge( FServer.FAuthDigestMethod, FServer.FAuthDigestServerSecret, FAuthRealm, '', FAuthDigestStale, FAuthDigestServerNonce, FAuthDigestServerOpaque) + #13#10; -- Arno Garrels -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Need help with HTTP/1.1 digest auth for forward proxy
Fastream Technologies wrote: Hi Arno, Ok, let me explain: due to stupid BCB linker errors,I had to place the function below in a pascal unit for calling the function you said: function THttpMTConnection.GenerateDigestChallenge : String; begin Result := AuthDigestGenerateChallenge( FServer.FAuthDigestMethod, FServer.FAuthDigestServerSecret, FAuthRealm, '', FAuthDigestStale, FAuthDigestServerNonce, FAuthDigestServerOpaque); end; And it still does not work. If you actually use the function above, why do you append stuff to the returned string at all? -- Arno Garrels Isn't there anybody with proxy authentication experience? I had basic and NTLM and HTML working fine--only digest left... Regards, SZ On Mon, Sep 21, 2009 at 9:38 AM, Arno Garrels arno.garr...@gmx.de wrote: Fastream Technologies wrote: headerHead += Proxy-Authenticate: Digest + // I only changed this line from rproxy to forward proxy GenerateDigestChallenge() + , domain=\ + prefix + FAuthRealm + : + serverPort + \ + , uri=\ + URI + \ + //, algorithm=\MD5\ + staleString + \r\n; This obviously is your own implementation, current ICS uses : function AuthDigestGenerateChallenge( DigestMethod: TAuthDigestMethod; Secret: TULargeInteger; const Realm, Domain : String; Stale: Boolean; var Nonce, Opaque: String): String; procedure THttpConnection.Answer401; [..] Header := Header + 'WWW-Authenticate: Digest ' + AuthDigestGenerateChallenge( FServer.FAuthDigestMethod, FServer.FAuthDigestServerSecret, FAuthRealm, '', FAuthDigestStale, FAuthDigestServerNonce, FAuthDigestServerOpaque) + #13#10; -- Arno Garrels -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Need help with HTTP/1.1 digest auth for forward proxy
Ok, that's a bug but not even with it fixed, it still does not work. Thanks, SZ On Mon, Sep 21, 2009 at 10:23 AM, Arno Garrels arno.garr...@gmx.de wrote: Fastream Technologies wrote: Hi Arno, Ok, let me explain: due to stupid BCB linker errors,I had to place the function below in a pascal unit for calling the function you said: function THttpMTConnection.GenerateDigestChallenge : String; begin Result := AuthDigestGenerateChallenge( FServer.FAuthDigestMethod, FServer.FAuthDigestServerSecret, FAuthRealm, '', FAuthDigestStale, FAuthDigestServerNonce, FAuthDigestServerOpaque); end; And it still does not work. If you actually use the function above, why do you append stuff to the returned string at all? -- Arno Garrels Isn't there anybody with proxy authentication experience? I had basic and NTLM and HTML working fine--only digest left... Regards, SZ On Mon, Sep 21, 2009 at 9:38 AM, Arno Garrels arno.garr...@gmx.de wrote: Fastream Technologies wrote: headerHead += Proxy-Authenticate: Digest + // I only changed this line from rproxy to forward proxy GenerateDigestChallenge() + , domain=\ + prefix + FAuthRealm + : + serverPort + \ + , uri=\ + URI + \ + //, algorithm=\MD5\ + staleString + \r\n; This obviously is your own implementation, current ICS uses : function AuthDigestGenerateChallenge( DigestMethod: TAuthDigestMethod; Secret: TULargeInteger; const Realm, Domain : String; Stale: Boolean; var Nonce, Opaque: String): String; procedure THttpConnection.Answer401; [..] Header := Header + 'WWW-Authenticate: Digest ' + AuthDigestGenerateChallenge( FServer.FAuthDigestMethod, FServer.FAuthDigestServerSecret, FAuthRealm, '', FAuthDigestStale, FAuthDigestServerNonce, FAuthDigestServerOpaque) + #13#10; -- Arno Garrels -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Need help with HTTP/1.1 digest auth for forward proxy
Hello Arno, I noticed I was using a derived-class variable called FRequestAuthorization and the function was looking for FRequestAuth! It's fine now! Thanks!! SZ On Mon, Sep 21, 2009 at 10:42 AM, Fastream Technologies ga...@fastream.comwrote: Ok, that's a bug but not even with it fixed, it still does not work. Thanks, SZ On Mon, Sep 21, 2009 at 10:23 AM, Arno Garrels arno.garr...@gmx.dewrote: Fastream Technologies wrote: Hi Arno, Ok, let me explain: due to stupid BCB linker errors,I had to place the function below in a pascal unit for calling the function you said: function THttpMTConnection.GenerateDigestChallenge : String; begin Result := AuthDigestGenerateChallenge( FServer.FAuthDigestMethod, FServer.FAuthDigestServerSecret, FAuthRealm, '', FAuthDigestStale, FAuthDigestServerNonce, FAuthDigestServerOpaque); end; And it still does not work. If you actually use the function above, why do you append stuff to the returned string at all? -- Arno Garrels Isn't there anybody with proxy authentication experience? I had basic and NTLM and HTML working fine--only digest left... Regards, SZ On Mon, Sep 21, 2009 at 9:38 AM, Arno Garrels arno.garr...@gmx.de wrote: Fastream Technologies wrote: headerHead += Proxy-Authenticate: Digest + // I only changed this line from rproxy to forward proxy GenerateDigestChallenge() + , domain=\ + prefix + FAuthRealm + : + serverPort + \ + , uri=\ + URI + \ + //, algorithm=\MD5\ + staleString + \r\n; This obviously is your own implementation, current ICS uses : function AuthDigestGenerateChallenge( DigestMethod: TAuthDigestMethod; Secret: TULargeInteger; const Realm, Domain : String; Stale: Boolean; var Nonce, Opaque: String): String; procedure THttpConnection.Answer401; [..] Header := Header + 'WWW-Authenticate: Digest ' + AuthDigestGenerateChallenge( FServer.FAuthDigestMethod, FServer.FAuthDigestServerSecret, FAuthRealm, '', FAuthDigestStale, FAuthDigestServerNonce, FAuthDigestServerOpaque) + #13#10; -- Arno Garrels -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Need help with HTTP/1.1 digest auth for forward proxy
I forgot to say: I also changed the parser for Authorization: request header to Proxy-Authorization: and that parser works well. But the problem remains. On Sun, Sep 20, 2009 at 11:24 AM, Fastream Technologies ga...@fastream.comwrote: Hello, Even though the code works for reverse proxy, it does not when I make it a part of IE/FF chain as forward proxy! In Answer401, I wrote: String AuthString = auth; String staleString = String((FAuthDigestStale lastCommand != cproxyCommandPOST) ? , stale=\true\ : ); String prefix = (Owner-Tag 0 ? https://; : http://;); String URI = FPath; headerHead += Proxy-Authenticate: Digest + // I only changed this line from rproxy to forward proxy GenerateDigestChallenge() + , domain=\ + prefix + FAuthRealm + : + serverPort + \ + , uri=\ + URI + \ + //, algorithm=\MD5\ + staleString + \r\n; and in ConnectionDataAvailable, before the processRequest ( I have my descendent of THttpServer by the way): else if(!FRequestAuthorization.SubString(1, 6).AnsiCompareIC(Digest)) { FAuthDigestBody = ; FAuthenticated = AuthDigestGetParams(); if(FAuthenticated) { username = FAuthUserName; // NO matter even the username is correct, never reaches here! String bufferPassword = serverPermissions-getUserPassword(username); I am not sure how to debug this as the data is encrypted. I know we were the pioneers in digest coding that we had had coded in Bulgaria and then Francois fixed it. But now it's a different story--forward proxy. Any idea what's wrong? The forward proxy units were copied from reverse proxy ones and then altered so the variable's reset points are exactly the same that has been working in rproxy. I hope you can help. Thanks in advance, SZ -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Need help with HTTP
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
Re: [twsocket] Need help with HTTP
Again my private email spam blocked.. :( Anyway, thanks for the reply. Will look at it later as my brain got fragmented... Best Regards, Gorkem Ates - Original Message - From: Francois PIETTE [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Saturday, September 02, 2006 11:00 AM Subject: Re: [twsocket] Need help with HTTP : 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
Re: [twsocket] Need help with HTTP
Hello, I have debugged the code to this point: { 26/11/2003: next 2 lines commented out to allow receiving data outside } { of any request (server push) } {if FState httpWaitingHeader then Exit; }{ Should never occur ! } while FReceiveLen 0 do begin I := Pos(#10, FReceiveBuffer); if I = 0 then begin break; // HERE end; This occurs when I reuse the same THttpCli connection, first HEAD then GET. I call InternalClear() and set the state to httpReady in between. I also check for any disconnection and abort then. I saw in OnDocData, header being in the Buffer variable. And in this code, there is no header/just data in FReceiveBuffer. I am puzzled and suffer a headache. ;0( Regards, SZ - Original Message - From: Francois PIETTE [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Saturday, September 02, 2006 11:00 AM Subject: Re: [twsocket] Need help with HTTP : 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
Re: [twsocket] Need help with HTTP
Hello, First of all, I would like to thank Ronny for his kind words on private email. (He finds my messages helpful! :) ). After a week of bug hunting I found the problem: I no longer call Abort() if the existing connection's IP/port is different than target's--I just let the component manage it. Best Regards, SZ - Original Message - From: Fastream Technologies [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Saturday, September 02, 2006 4:52 PM Subject: Re: [twsocket] Need help with HTTP : Hello, : : I have debugged the code to this point: : : : { 26/11/2003: next 2 lines commented out to allow receiving data outside } : { of any request (server push) } : {if FState httpWaitingHeader then :Exit; }{ Should never occur ! } : :while FReceiveLen 0 do begin :I := Pos(#10, FReceiveBuffer); :if I = 0 then begin :break; // HERE :end; : : This occurs when I reuse the same THttpCli connection, first HEAD then GET. : I call InternalClear() and set the state to httpReady in between. I also : check for any disconnection and abort then. : : I saw in OnDocData, header being in the Buffer variable. And in this code, : there is no header/just data in FReceiveBuffer. I am puzzled and suffer a : headache. ;0( : : Regards, : : SZ : : - Original Message - : From: Francois PIETTE [EMAIL PROTECTED] : To: ICS support mailing twsocket@elists.org : Sent: Saturday, September 02, 2006 11:00 AM : Subject: Re: [twsocket] Need help with HTTP : : :: 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