You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by pr...@apache.org on 2006/01/30 18:59:42 UTC

svn commit: r373556 - in /webservices/axis/trunk/c/src/transport/axis3: HTTPChannel/HTTPChannel.cpp HTTPChannel/HTTPChannel.hpp HTTPSSLChannel/HTTPSSLChannel.cpp HTTPSSLChannel/HTTPSSLChannel.hpp HTTPTransport.cpp IChannel.hpp

Author: prestonf
Date: Mon Jan 30 09:59:33 2006
New Revision: 373556

URL: http://svn.apache.org/viewcvs?rev=373556&view=rev
Log:
The current transport/channels cannot handle a SOAP message whose http header in which neither a chunked or message length is defined.
If the message is not chunked or a message length given, then 'Connection: close' must be specified.  In this case, the message is ended when the server closes the connection.

Modified:
    webservices/axis/trunk/c/src/transport/axis3/HTTPChannel/HTTPChannel.cpp
    webservices/axis/trunk/c/src/transport/axis3/HTTPChannel/HTTPChannel.hpp
    webservices/axis/trunk/c/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.cpp
    webservices/axis/trunk/c/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.hpp
    webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.cpp
    webservices/axis/trunk/c/src/transport/axis3/IChannel.hpp

Modified: webservices/axis/trunk/c/src/transport/axis3/HTTPChannel/HTTPChannel.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/transport/axis3/HTTPChannel/HTTPChannel.cpp?rev=373556&r1=373555&r2=373556&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/transport/axis3/HTTPChannel/HTTPChannel.cpp (original)
+++ webservices/axis/trunk/c/src/transport/axis3/HTTPChannel/HTTPChannel.cpp Mon Jan 30 09:59:33 2006
@@ -39,6 +39,8 @@
     m_lTimeoutSeconds = 0;
 #endif
 
+	bNoExceptionOnForceClose = false;
+
     if( !StartSockets())
     {
         throw HTTPTransportException( SERVER_TRANSPORT_CHANNEL_INIT_ERROR);
@@ -240,8 +242,11 @@
 
         CloseChannel();
 
-        throw HTTPTransportException( SERVER_TRANSPORT_INPUT_STREAMING_ERROR, 
-                                      (char *) m_LastError.c_str());
+		if( !bNoExceptionOnForceClose)
+		{
+	        throw HTTPTransportException( SERVER_TRANSPORT_INPUT_STREAMING_ERROR, 
+		                                  (char *) m_LastError.c_str());
+		}
     }
 
     if( nByteRecv)
@@ -753,4 +758,9 @@
     sprintf( szMsg, "%s %d %s: '%s'\n", szText1, (int) dwMsg, szText2, sMsg->c_str());
 
     m_LastError = szMsg;
+}
+
+void HTTPChannel::closeQuietly( bool bNoExceptionOnForceClose_Update)
+{
+	bNoExceptionOnForceClose = bNoExceptionOnForceClose_Update;
 }

Modified: webservices/axis/trunk/c/src/transport/axis3/HTTPChannel/HTTPChannel.hpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/transport/axis3/HTTPChannel/HTTPChannel.hpp?rev=373556&r1=373555&r2=373556&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/transport/axis3/HTTPChannel/HTTPChannel.hpp (original)
+++ webservices/axis/trunk/c/src/transport/axis3/HTTPChannel/HTTPChannel.hpp Mon Jan 30 09:59:33 2006
@@ -77,10 +77,12 @@
     const IChannel &	operator << (const char * msg);
     void				setTimeout( long lSeconds);
     void				setSocket( unsigned int uiNewSocket);
+	int					getSocket() {return m_Sock;}
 	bool				setTransportProperty( AXIS_TRANSPORT_INFORMATION_TYPE type, const char * value);
 	const char *		getTransportProperty( AXIS_TRANSPORT_INFORMATION_TYPE type);
     void				setProxy( const char * pcProxyHost, unsigned int uiProxyPort);
 	virtual bool		reopenRequired() throw() { return false; }
+	void				closeQuietly( bool bNoExceptionOnForceClose);
 
 protected:
 	bool				OpenChannel();
@@ -96,11 +98,14 @@
 #ifdef WIN32
     unsigned 
 #endif
-    int	m_Sock;				      // Socket descriptor
-    bool			m_bUseProxy;		// Use a Proxy?
-    std::string		m_strProxyHost;		// Proxy server name.
-    unsigned int	m_uiProxyPort;		// Proxy server port.
-    long			m_lTimeoutSeconds;	// Timeout in seconds
+    int				m_Sock;						// Socket descriptor
+    bool			m_bUseProxy;				// Use a Proxy?
+    std::string		m_strProxyHost;				// Proxy server name.
+    unsigned int	m_uiProxyPort;				// Proxy server port.
+    long			m_lTimeoutSeconds;			// Timeout in seconds
+	bool			bNoExceptionOnForceClose;	// If the socket is forcably closed, usually an
+												// exception is thrown.  When this flag is set,
+												// nothing happens (but the m_Sock is set to 0).
 };
 
 #endif

Modified: webservices/axis/trunk/c/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.cpp?rev=373556&r1=373555&r2=373556&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.cpp (original)
+++ webservices/axis/trunk/c/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.cpp Mon Jan 30 09:59:33 2006
@@ -57,6 +57,8 @@
 	m_lTimeoutSeconds = 0;
 #endif
 
+	bNoExceptionOnForceClose = false;
+
 	if( !StartSockets())
 	{
 		throw HTTPTransportException( SERVER_TRANSPORT_CHANNEL_INIT_ERROR);
@@ -709,9 +711,16 @@
     if(nByteRecv < 0)
     {
 // failed SSL_read
-        OpenSSL_SetSecureError( SSL_get_error( m_sslHandle, nByteRecv));
+		if( !bNoExceptionOnForceClose)
+		{
+	        OpenSSL_SetSecureError( SSL_get_error( m_sslHandle, nByteRecv));
+		}
 
         OpenSSL_Close();
+
+		::close();
+
+		m_Sock = INVALID_SOCKET; // fix for AXISCPP-185
     }
 	else
     {
@@ -927,4 +936,9 @@
             throw HTTPTransportException( CLIENT_SSLCHANNEL_ERROR, error_buffer);
         }
     }
+}
+
+void HTTPSSLChannel::closeQuietly( bool bNoExceptionOnForceClose_Update)
+{
+	bNoExceptionOnForceClose = bNoExceptionOnForceClose_Update;
 }

Modified: webservices/axis/trunk/c/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.hpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.hpp?rev=373556&r1=373555&r2=373556&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.hpp (original)
+++ webservices/axis/trunk/c/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.hpp Mon Jan 30 09:59:33 2006
@@ -79,10 +79,12 @@
     const IChannel &	operator << (const char * msg);
     void				setTimeout( long lSeconds);
     void				setSocket( unsigned int uiNewSocket);
+	int					getSocket() {return m_Sock};
 	bool				setTransportProperty( AXIS_TRANSPORT_INFORMATION_TYPE type, const char* value);
 	const char *		getTransportProperty( AXIS_TRANSPORT_INFORMATION_TYPE type);
     void				setProxy( const char * pcProxyHost, unsigned int uiProxyPort);
 	virtual bool		reopenRequired() throw() { return false; }
+	void				closeQuietly( bool bNoExceptionOnForceClose);
 
 protected:
 	bool				OpenChannel();
@@ -103,13 +105,16 @@
 #ifdef WIN32
     unsigned 
 #endif
-    int	m_Sock;				// Socket descriptor
-    bool			m_bUseProxy;		// Use a Proxy?
-    string			m_strProxyHost;		// Proxy server name.
-    unsigned int	m_uiProxyPort;		// Proxy server port.
-    long			m_lTimeoutSeconds;	// Timeout in seconds
 	SSL_CTX *		m_sslContext;
 	SSL *			m_sslHandle;
+    int				m_Sock;						// Socket descriptor
+    bool			m_bUseProxy;				// Use a Proxy?
+    std::string		m_strProxyHost;				// Proxy server name.
+    unsigned int	m_uiProxyPort;				// Proxy server port.
+    long			m_lTimeoutSeconds;			// Timeout in seconds
+	bool			bNoExceptionOnForceClose;	// If the socket is forcably closed, usually an
+												// exception is thrown.  When this flag is set,
+												// nothing happens (but the m_Sock is set to 0).
 };
 
 #endif

Modified: webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.cpp?rev=373556&r1=373555&r2=373556&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.cpp (original)
+++ webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.cpp Mon Jan 30 09:59:33 2006
@@ -641,8 +641,11 @@
 
 		case eSOAPMessageIsNotChunked:
 		{
-		// Check that there is more message to read.
-			if( m_iContentLength > 0)
+		// Check that there is more message to read.  Or, if the message has no
+		// length defined, keep reading until the connection is closed by the
+		// server.
+			if( m_iContentLength > 0 ||
+				(m_bReopenConnection && m_pActiveChannel->getSocket()))
 			{
 				getNextDataPacket( "No data available for message.");
 
@@ -660,7 +663,18 @@
 		// If all of the message has been received, then reset the process state.
 				if( m_iContentLength <= 0)
 				{
-					m_GetBytesState = eWaitingForHTTPHeader;
+		// The content length is <= 0, BUT the m_bReopenConnection is true
+		// (because a 'Connection: close' has been found) the socket has been
+		// closed by the server, then wait for the next HTTP message, otherwise
+		// keep reading!
+					if( m_bReopenConnection && m_pActiveChannel->getSocket())
+					{
+						m_iContentLength = 0;
+					}
+					else
+					{
+						m_GetBytesState = eWaitingForHTTPHeader;
+					}
 				}
 			}
 			else
@@ -1157,11 +1171,15 @@
 			if( key == "Connection" && (value == " close" || value == " Close"))
 			{
 				m_bReopenConnection = true;
+
+				m_pActiveChannel->closeQuietly( true);
 			}
 
             // We need to close the connection and open a new one if we have 'Proxy-Connection: close'
             if (key == "Proxy-Connection" && (value == " close" || value == " Close"))
+			{
                 m_bReopenConnection = true;
+			}
 
 	    	// For both HTTP/1.0 and HTTP/1.1,
 	    	// We need to keep the connection if we have 'Connection: Keep-Alive'
@@ -1602,6 +1620,8 @@
 
 	m_strReceived = "";
 
+	m_pActiveChannel->closeQuietly( false);
+
 	do
 	{
 // Read whatever part of the response message that has arrived at the active
@@ -1690,7 +1710,7 @@
 			m_GetBytesState = eSOAPMessageIsNotChunked;
 			m_iBytesLeft = m_strReceived.substr( iHTTPEnd + 2).length();
 
-// Check if all the message has already been recieved.  If not, then subtract
+// Check if all the message has already been received.  If not, then subtract
 // that bit that has been from the total length.  If so, then make the content
 // length equal to zero.
 			if( m_iContentLength >= m_iBytesLeft)

Modified: webservices/axis/trunk/c/src/transport/axis3/IChannel.hpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/transport/axis3/IChannel.hpp?rev=373556&r1=373555&r2=373556&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/transport/axis3/IChannel.hpp (original)
+++ webservices/axis/trunk/c/src/transport/axis3/IChannel.hpp Mon Jan 30 09:59:33 2006
@@ -49,10 +49,12 @@
 	virtual const char *		getSecureProperties() {return NULL;};
     virtual void				setTimeout( long lSeconds)=0;
     virtual void				setSocket( unsigned int uiNewSocket)=0;
+    virtual int					getSocket()=0;
 	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;
+	virtual void				closeQuietly( bool bNoExceptionOnForceClose) = 0;
 };
 
 #endif