Bug 147812 - HTTP responses containing just a header cause Konqueror to wait indefinitely for a response
Summary: HTTP responses containing just a header cause Konqueror to wait indefinitely ...
Status: RESOLVED FIXED
Alias: None
Product: kio
Classification: Frameworks and Libraries
Component: http (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-12 16:04 UTC by Robert Hogan
Modified: 2007-09-01 21:14 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Hogan 2007-07-12 16:04:59 UTC
Version:            (using KDE KDE 3.5.7)
Installed from:    Compiled From Sources
Compiler:          gcc 
OS:                Linux

HTTP Responses along the lines of:

"HTTP/1.0 503 Network Object Not Available\r\n\r\n"

with no body after the header cause Konqueror to wait indefinitely. This is because kio_http is expecting the error to be reported in a body element, e.g. an html-ized version of the error from Apache, and never gives anything back to the client.

Try http://moria.csail.mit.edu:9031/tor/status/rob to see what I mean.

When there is a zero-length body in a HTTP response, kio_http needs to report the http response code to the client. The following does this in HTTPProtocol::readBody() for the two likeliest which have a corresponding error() response in HTTPProtocol::readHeader(). It defaults to ERR_NO_CONTENT for all other cases, which may or may not be the right thing to do.

Index: kdelibs/kioslave/http/http.cc
===================================================================
--- kdelibs/kioslave/http/http.cc       (revision 686951)
+++ kdelibs/kioslave/http/http.cc       (working copy)
@@ -4443,6 +4443,8 @@
       chain.addFilter(new HTTPFilterDeflate);
   }

+  int totalBytesReceived=0;
+
   while (!m_bEOF)
   {
     int bytesReceived;
@@ -4454,10 +4456,23 @@
     else
        bytesReceived = readUnlimited();

+    totalBytesReceived += bytesReceived;
+
     // make sure that this wasn't an error, first
     // kdDebug(7113) << "(" << (int) m_pid << ") readBody: bytesReceived: "
     //              << (int) bytesReceived << " m_iSize: " << (int) m_iSize << " Chunked: "
     //              << (int) m_bChunked << " BytesLeft: "<< (int) m_iBytesLeft << endl;
+
+    if (totalBytesReceived == 0){
+      if (m_responseCode >= 500 && m_responseCode <= 599)
+        error(ERR_INTERNAL_SERVER, m_state.hostname);
+      else if (m_responseCode >= 400 && m_responseCode <= 499)
+        error(ERR_DOES_NOT_EXIST, m_state.hostname);
+      else
+        error(ERR_NO_CONTENT, m_state.hostname);
+      return false;
+    }
+
     if (bytesReceived == -1)
     {
       if (m_iContentLeft == 0)
Comment 1 Robert Hogan 2007-07-12 16:07:06 UTC
As a sidenote: Firefox, Opera and wget all handle http://moria.csail.mit.edu:9031/tor/status/rob gracefully.
Comment 2 Philip Rodrigues 2007-07-13 22:36:07 UTC
Confirmed here
Comment 3 Dawit Alemayehu 2007-09-01 21:14:51 UTC
SVN commit 707403 by adawit:

- Do not assume that the server will send error pages on 4xx and 5xx response. Fixes 147812.

BUG:147812


 M  +8 -0      http.cpp  


--- trunk/KDE/kdelibs/kioslave/http/http.cpp #707402:707403
@@ -4399,6 +4399,14 @@
         closeCacheEntry();
   }
 
+  if (sz <= 1)
+  {
+    if (m_responseCode >= 500 && m_responseCode <= 599)
+      error(ERR_INTERNAL_SERVER, m_state.hostname);
+    else if (m_responseCode >= 400 && m_responseCode <= 499)
+      error(ERR_DOES_NOT_EXIST, m_state.hostname);
+  }
+
   if (!dataInternal)
     data( QByteArray() );
   return true;