From kfm-devel Sat Mar 30 17:35:41 2002 From: Dawit Date: Sat, 30 Mar 2002 17:35:41 +0000 To: kfm-devel Subject: PATCH: kio_http re-POST problems on connection failure X-MARC-Message: https://marc.info/?l=kfm-devel&m=101751016227655 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--------------Boundary-00=_HJRSX6RFGO0F8X8DT2RO" --------------Boundary-00=_HJRSX6RFGO0F8X8DT2RO Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi, This is a patch to fix the problem frist reported by Lars where kio_http = fails=20 to re-post data properly if the connection with the server is severed aft= er=20 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 t= he said problem, please test and let me know if there is a problem. Regards, Dawit A. --------------Boundary-00=_HJRSX6RFGO0F8X8DT2RO Content-Type: text/x-diff; charset="us-ascii"; name="http.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="http.patch" 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( "%1 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 ); --------------Boundary-00=_HJRSX6RFGO0F8X8DT2RO--