You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by cd...@apache.org on 2005/08/23 05:23:32 UTC

cvs commit: ws-axis/c/src/transport/axis3 HTTPTransport.cpp IChannel.hpp

cdinapala    2005/08/22 20:23:32

  Modified:    c/src/transport/axis3 HTTPTransport.cpp IChannel.hpp
  Log:
  I have done some modifications as suggest in issue AXISCPP-558.
  With changes build and tests are working fine.
  
  Revision  Changes    Path
  1.39      +89 -27    ws-axis/c/src/transport/axis3/HTTPTransport.cpp
  
  Index: HTTPTransport.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/transport/axis3/HTTPTransport.cpp,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- HTTPTransport.cpp	8 Aug 2005 09:40:15 -0000	1.38
  +++ HTTPTransport.cpp	23 Aug 2005 03:23:32 -0000	1.39
  @@ -285,6 +285,25 @@
    */
   AXIS_TRANSPORT_STATUS HTTPTransport::flushOutput() throw (AxisException, HTTPTransportException)
   {
  +	//Chinthana:AXISCPP-558 - Gracefully handle server side close of persistant connection
  +	if( m_bReopenConnection)
  +	{
  +		m_bReopenConnection = false;
  +  
  + 		if( m_pActiveChannel->open() != AXIS_SUCCESS)
  + 		{
  + 		    int				iStringLength = m_pActiveChannel->GetLastErrorMsg().length() + 1;
  + 			const char *	pszLastError = new char[iStringLength];
  +  
  + 		    memcpy( (void *) pszLastError,
  +  					m_pActiveChannel->GetLastErrorMsg().c_str(),
  +  					iStringLength);
  +  
  + 		    throw HTTPTransportException( CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED,(char *) pszLastError);
  +		}
  +	}
  +	//16-08-2005.................................................
  +	
       // In preperation for sending the message, calculate the size of the message
       // by using the string length method.
       // NB: This calculation may not necessarily be correct when dealing with SSL
  @@ -296,35 +315,78 @@
   
       this->setTransportProperty ("Content-Length", buff);
   
  +	//Chinthana:AXISCPP-558 - Gracefully handle server side close of persistant connection
  +	bool reopenConnection;
  + 	if (m_pActiveChannel->reopenRequired())
  +	{
  + 		reopenConnection = true;
  + 	}
  + 	else 
  +	{
  + 		reopenConnection = m_bReopenConnection;
  + 		m_bReopenConnection = false;
  + 	}
  + 
  + 	bool reopenConnectionOnFailure = true;
  + 	bool dataSent = false;
  + 
  + 	while (!dataSent) 
  +	{
  + 		if( reopenConnection ) 
  +		{
  + 			m_pActiveChannel->close();
  + 
  + 			if( m_pActiveChannel->open() != AXIS_SUCCESS)
  + 			{
  + 				int iStringLength = m_pActiveChannel->GetLastErrorMsg().length() + 1;
  + 				const char* pszLastError = new char[iStringLength];
  + 
  + 				memcpy( (void *) pszLastError,
  +  					m_pActiveChannel->GetLastErrorMsg().c_str(),
  +  					iStringLength);
  +  
  + 				throw HTTPTransportException( CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED,
  + 							      (char *) pszLastError);
  +  			}
  +  
  + 			// Only attempt to reopen the connection one time
  + 			reopenConnectionOnFailure = false;
  + 		}
  +	//16-08-2005.................................................
  +
       // The header is now complete.  The message header and message can now be
       // transmitted.
  -	try
  -	{
  -#ifndef __OS400__
  -		*m_pActiveChannel << this->getHTTPHeaders ();
  -		*m_pActiveChannel << this->m_strBytesToSend.c_str ();
  -#else		
  -        const char *buf = this->getHTTPHeaders ();
  -        char *utf8Buf = toUTF8((char *)buf, strlen(buf)+1);
  -		*m_pActiveChannel << utf8Buf;
  -        free(utf8Buf);
  -        buf     = this->m_strBytesToSend.c_str();
  -        utf8Buf = toUTF8((char *)buf, strlen(buf)+1);
  -		*m_pActiveChannel << utf8Buf;
  -        free(utf8Buf);
  -#endif
  -	}
  -	catch( HTTPTransportException & e)
  -	{
  -		throw;
  -	}
  -	catch( AxisException & e)
  -	{
  -		throw;
  -	}
  -	catch(...)
  -	{
  -		throw;
  +		try
  +		{
  +			#ifndef __OS400__
  +					*m_pActiveChannel << this->getHTTPHeaders ();
  +					*m_pActiveChannel << this->m_strBytesToSend.c_str ();
  +			#else		
  +					const char *buf = this->getHTTPHeaders ();
  +					char *utf8Buf = toUTF8((char *)buf, strlen(buf)+1);
  +					*m_pActiveChannel << utf8Buf;
  +					free(utf8Buf);
  +					buf     = this->m_strBytesToSend.c_str();
  +					utf8Buf = toUTF8((char *)buf, strlen(buf)+1);
  +					*m_pActiveChannel << utf8Buf;
  +					free(utf8Buf);
  +			#endif
  +			// Chinthana: We're done sending
  +			dataSent = true;
  +
  +		}
  +		catch( HTTPTransportException & e)
  +		{
  +			throw;
  +		}
  +		catch( AxisException & e)
  +		{
  +			throw;
  +		}
  +		catch(...)
  +		{
  +			throw;
  +		}
   	}
   
       // Empty the bytes to send string.
  
  
  
  1.8       +1 -0      ws-axis/c/src/transport/axis3/IChannel.hpp
  
  Index: IChannel.hpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/transport/axis3/IChannel.hpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- IChannel.hpp	23 Mar 2005 15:45:02 -0000	1.7
  +++ IChannel.hpp	23 Aug 2005 03:23:32 -0000	1.8
  @@ -51,6 +51,7 @@
   	virtual bool				setTransportProperty( AXIS_TRANSPORT_INFORMATION_TYPE type, const char* value)=0;
   	virtual const char *		getTransportProperty( AXIS_TRANSPORT_INFORMATION_TYPE type)=0;
   	virtual void                setProxy(const char *pcProxyHost,unsigned int uiProxyPort) = 0;
  +	virtual bool				reopenRequired() throw() = 0;
   };
   
   #endif