[prev in list] [next in list] [prev in thread] [next in thread] 

List:       helix-filesystem-cvs
Subject:    [Filesystem-cvs] http httpfsys.cpp,1.72.2.17,1.72.2.18
From:       ping () helixcommunity ! org
Date:       2006-09-01 5:56:27
[Download RAW message or body]

Update of /cvsroot/filesystem/http
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv29013

Modified Files:
      Tag: hxclient_1_5_0_cayenne
	httpfsys.cpp 
Log Message:
I need to check this in to Cay150 so it can be in nightly Rhapsody build for \
tomorrow's QA.

Description:
~~~~~~~~~~~~~~~~~
There is web server outta there doesn't include "Content-Length" field in its HTTP \
GET response with Entity-Body, in such case, our HTTP file system fails to mark \
m_bReadContentsDone and it keeps waiting for data coming in even though the socket \
has been closed by the server.

According to RFC1945(HTTP1.0), Section 7.2.2:
"
   When an Entity-Body is included with a message, the length of that
   body may be determined in one of two ways. If a Content-Length header
   field is present, its value in bytes represents the length of the
   Entity-Body. Otherwise, the body length is determined by the closing
   of the connection by the server.
"

So, the fix is to call SetReadContentsDone(TRUE) when the socket is closed by the \
server. 

The other change inside SetReadContentsDone is to make sure the Progressive Download \
logic is only executed the first time SetReadContentsDone(TRUE) is called.



Index: httpfsys.cpp
===================================================================
RCS file: /cvsroot/filesystem/http/httpfsys.cpp,v
retrieving revision 1.72.2.17
retrieving revision 1.72.2.18
diff -u -d -r1.72.2.17 -r1.72.2.18
--- httpfsys.cpp	26 Jul 2006 07:58:23 -0000	1.72.2.17
+++ httpfsys.cpp	1 Sep 2006 05:56:24 -0000	1.72.2.18
@@ -1089,42 +1089,53 @@
 void
 CHTTPFileObject::SetReadContentsDone(HXBOOL bReadContentsDone)
 {
-    m_bReadContentsDone = bReadContentsDone;
-#if defined(HELIX_FEATURE_PROGRESSIVE_DOWNLD_STATUS)
-    if (m_pBytesToDur  &&  bReadContentsDone)
+    // SetReadContentDone(TRUE) can be called from multipe places
+    // the PD logic below should only be executed the first time
+    // SetReadContentsDone(TRUE) is called
+    if (!m_bReadContentsDone && bReadContentsDone)
     {
-        // /We're done downloading so call one last bytes-to-dur conversion
-        // (which will kick off an OnDownloadComplete() in FF's that
-        // implement it):
-        UINT32 ulFileSizeDownloaded = m_ulPrgDnTotalFileSize;
-        m_ulFileSizeSoFar = ulFileSizeDownloaded;
-        if (!m_bKnowContentSize &&
-                m_ulPrgDnTotalFileSize == HX_PROGDOWNLD_UNKNOWN_FILE_SIZE)
-        {
-            // /We haven't been told the total file size so assume the total
-            // file size is what we were able to download:
-            ulFileSizeDownloaded = m_ulCurrentReadPosition +
-                    m_pChunkyRes->GetContiguousLength(m_ulCurrentReadPosition);
-        }
-        UINT32 ulPrevDurOfBytesSoFar = m_ulCurrentDurOfBytesSoFar;
-        m_pBytesToDur->ConvertFileOffsetToDur(
-                ulFileSizeDownloaded,
-                ulFileSizeDownloaded,
-                /*REF*/ m_ulCurrentDurOfBytesSoFar);
-        m_ulPrgDnTotalFileDur = m_ulCurrentDurOfBytesSoFar;
-        // /If we haven't yet reported download complete or if we have but
-        // dur has changed, then notify observers:
-        if (!m_bDownloadCompleteReported  ||
-                ulPrevDurOfBytesSoFar != m_ulCurrentDurOfBytesSoFar)
+        m_bReadContentsDone = bReadContentsDone;
+
+#if defined(HELIX_FEATURE_PROGRESSIVE_DOWNLD_STATUS)
+        if (m_pBytesToDur)
         {
-            ReportCurrentDurChanged();
-            // /NOTE: if we got here because download stopped early, then this
-            // will report a lower-than-entire-file-duration value:
-            ReportTotalDurChanged();
-            ReportDownloadComplete();
+            // /We're done downloading so call one last bytes-to-dur conversion
+            // (which will kick off an OnDownloadComplete() in FF's that
+            // implement it):
+            UINT32 ulFileSizeDownloaded = m_ulPrgDnTotalFileSize;
+            m_ulFileSizeSoFar = ulFileSizeDownloaded;
+            if (!m_bKnowContentSize &&
+                    m_ulPrgDnTotalFileSize == HX_PROGDOWNLD_UNKNOWN_FILE_SIZE)
+            {
+                // /We haven't been told the total file size so assume the total
+                // file size is what we were able to download:
+                ulFileSizeDownloaded = m_ulCurrentReadPosition +
+                        m_pChunkyRes->GetContiguousLength(m_ulCurrentReadPosition);
+            }
+            UINT32 ulPrevDurOfBytesSoFar = m_ulCurrentDurOfBytesSoFar;
+            m_pBytesToDur->ConvertFileOffsetToDur(
+                    ulFileSizeDownloaded,
+                    ulFileSizeDownloaded,
+                    /*REF*/ m_ulCurrentDurOfBytesSoFar);
+            m_ulPrgDnTotalFileDur = m_ulCurrentDurOfBytesSoFar;
+            // /If we haven't yet reported download complete or if we have but
+            // dur has changed, then notify observers:
+            if (!m_bDownloadCompleteReported  ||
+                    ulPrevDurOfBytesSoFar != m_ulCurrentDurOfBytesSoFar)
+            {
+                ReportCurrentDurChanged();
+                // /NOTE: if we got here because download stopped early, then this
+                // will report a lower-than-entire-file-duration value:
+                ReportTotalDurChanged();
+                ReportDownloadComplete();
+            }
         }
-    }
 #endif // /HELIX_FEATURE_PROGRESSIVE_DOWNLD_STATUS.
+    }
+    else
+    {
+        m_bReadContentsDone = bReadContentsDone;
+    }
 }
 
 
@@ -4481,6 +4492,9 @@
         }
         else if (HXR_SOCK_ENDSTREAM == retVal)
         {
+            // we need to assume we have read all the content body if the socket was \
closed by the server. +            SetReadContentsDone(TRUE);
+
             // normal end of data reached
             if( m_pSocket )
             {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic