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

List:       kfm-devel
Subject:    PATCH: kio_http re-POST problems on connection failure
From:       Dawit <adawit () kde ! org>
Date:       2002-03-30 17:35:41
[Download RAW message or body]

Hi,

This is a patch to fix the problem frist reported by Lars where kio_http fails 
to re-post data properly if the connection with the server is severed after 
sending the header.  It will correctly attempt the re-connection, but it does
fails to send the data when the current request was a POST.

I want to apply this patch to the KDE_3_0_BRANCH ; so everyone that had the
said problem, please test and let me know if there is a problem.

Regards,
Dawit A.
["http.patch" (text/x-diff)]

Index: http.cc
===================================================================
RCS file: /home/kde/kdelibs/kioslave/http/http.cc,v
retrieving revision 1.470
diff -u -p -b -B -w -r1.470 http.cc
--- http.cc	2002/03/23 04:26:55	1.470
+++ http.cc	2002/03/30 17:16:22
@@ -2132,10 +2124,8 @@ bool HTTPProtocol::httpOpen()

   bool res = true;

-  if ( moreData )
+  if ( moreData || davData )
     res = sendBody();
-  else if ( davData )
-    res = sendBody( true );

   infoMessage( i18n( "<b>%1</b> contacted. "
                      "Waiting for reply..." ).arg( m_request.hostname ) );
@@ -3050,7 +3059,7 @@ void HTTPProtocol::addEncoding(QString e
   }
 }

-bool HTTPProtocol::sendBody( bool dataInternal /* = false */ )
+bool HTTPProtocol::sendBody()
 {
   int result=-1;
   int length=0;
@@ -3059,15 +3068,14 @@ bool HTTPProtocol::sendBody( bool dataIn

   // Loop until we got 'dataEnd'
   kdDebug(7113) << "(" << m_pid << ") Response code: " << m_responseCode << endl;
-  if ( m_responseCode == 401 || m_responseCode == 407 || dataInternal )
-  {
-    // For RE-POST on authentication failure the
-    // buffer should not be empty...
-    if ( m_bufPOST.isNull() )
+
+  // if ( m_responseCode == 401 || m_responseCode == 407 || dataInternal )
+
+  // m_bufPOST will NOT be empty iff authentication was required before posting
+  // the data OR a re-connect is requested from ::readHeader because the
+  // connection was lost for some reason.
+  if ( !m_bufPOST.isNull() )
     {
-      error( ERR_ABORTED, m_request.hostname );
-      return false;
-    }
     kdDebug(7113) << "(" << m_pid << ") POST'ing saved data..." << endl;
     length = m_bufPOST.size();
     result = 0;
@@ -3093,7 +3101,7 @@ bool HTTPProtocol::sendBody( bool dataIn
     } while ( result > 0 );
   }

-  if ( result != 0 )
+  if ( result < 0 )
   {
     error( ERR_ABORTED, m_request.hostname );
     return false;
Index: http.h
===================================================================
RCS file: /home/kde/kdelibs/kioslave/http/http.h,v
retrieving revision 1.123
diff -u -p -b -B -w -r1.123 http.h
--- http.h	2002/03/22 01:57:37	1.123
+++ http.h	2002/03/30 17:27:26
@@ -225,12 +230,11 @@ protected:
   bool httpOpenConnection();   // Open connection
   void httpCheckConnection();  // Check whether to keep connection.
   void httpCloseConnection();  // Close conection
-  bool httpIsConnected();      // Checks for existing connection.

   bool readHeader();
-  // where dataInternal == true, the content is to come from
-  // an internal function.
-  bool sendBody( bool dataInternal = false );
+
+  bool sendBody();
+
   // where dataInternal == true, the content is to be made available
   // to an internal function.
   bool readBody( bool dataInternal = false );


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

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