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 sa...@apache.org on 2006/02/10 06:30:31 UTC

svn commit: r376564 - in /webservices/axis2/trunk/c/modules/core/transport/http: http_transport_utils.c sender/soap_over_http_sender.c

Author: sahan
Date: Thu Feb  9 21:30:29 2006
New Revision: 376564

URL: http://svn.apache.org/viewcvs?rev=376564&view=rev
Log:
Fixed a bug in callback function as well as the soap over http sender for not taking the content length into account

Modified:
    webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c
    webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c

Modified: webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c?rev=376564&r1=376563&r2=376564&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c Thu Feb  9 21:30:29 2006
@@ -782,7 +782,8 @@
 		axis2_stream_t *in_stream = NULL;
         int read_len = 0;
         in_stream = (axis2_stream_t *)((axis2_callback_info_t*)ctx)->in_stream;
-        if(size > ((axis2_callback_info_t*)ctx)->unread_len)
+        if(size > ((axis2_callback_info_t*)ctx)->unread_len && 
+						-1 != ((axis2_callback_info_t*)ctx)->unread_len)
         {
             read_len = ((axis2_callback_info_t*)ctx)->unread_len;
         }
@@ -811,6 +812,7 @@
     axis2_stream_t *in_stream = NULL;
     axis2_callback_info_t callback_ctx;
 	axis2_char_t *trans_enc = NULL;
+	int *content_length = NULL;
     AXIS2_ENV_CHECK(env, NULL);
 	AXIS2_PARAM_CHECK((*env)->error, msg_ctx, NULL);
     AXIS2_PARAM_CHECK((*env)->error, soap_ns_uri, NULL);
@@ -823,6 +825,13 @@
 	callback_ctx.unread_len = -1;
 	callback_ctx.chunked_stream = NULL;
 	
+	content_length = AXIS2_MSG_CTX_GET_PROPERTY(msg_ctx, env, 
+						AXIS2_HTTP_HEADER_CONTENT_LENGTH, AXIS2_FALSE);
+	if(content_length != NULL)
+	{
+		callback_ctx.content_length = *content_length;
+		callback_ctx.unread_len = *content_length;
+	}
     if(NULL == in_stream)
     {
         AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NULL_IN_STREAM_IN_MSG_CTX,

Modified: webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c?rev=376564&r1=376563&r2=376564&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c Thu Feb  9 21:30:29 2006
@@ -315,6 +315,8 @@
 	axis2_char_t *charset = NULL;
 	axis2_soap_over_http_sender_impl_t *sender_impl = NULL;
 	int i = 0;
+	axis2_bool_t response_chunked = AXIS2_FALSE;
+	int *content_length = NULL;
 	
 	AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
 	AXIS2_PARAM_CHECK((*env)->error, msg_ctx, AXIS2_FAILURE);
@@ -345,6 +347,7 @@
 						AXIS2_HTTP_HEADER_TRANSFER_ENCODING, 
 						AXIS2_HTTP_HEADER_TRANSFER_ENCODING_CHUNKED,
 						AXIS2_FALSE);
+				response_chunked = AXIS2_TRUE;
 			}
 			if(0 != AXIS2_STRCMP(name, AXIS2_HTTP_HEADER_CONTENT_TYPE))
 			{
@@ -369,6 +372,20 @@
 			AXIS2_CTX_SET_PROPERTY(axis_ctx, env, AXIS2_CHARACTER_SET_ENCODING, 
 						(void*)charset, AXIS2_FALSE);
 		}
+	}
+	if(AXIS2_FALSE == response_chunked)
+	{
+		int tmp_len = 0;
+		content_length = AXIS2_MALLOC((*env)->allocator, sizeof(int));
+		if(NULL == content_length)
+		{
+			return AXIS2_FAILURE;
+		}
+		tmp_len = AXIS2_HTTP_SIMPLE_RESPONSE_GET_CONTENT_LENGTH(response, env);
+		memcpy(content_length, &tmp_len, sizeof(int));
+		AXIS2_MSG_CTX_SET_PROPERTY(msg_ctx, env, 
+						AXIS2_HTTP_HEADER_CONTENT_LENGTH, content_length, 
+						AXIS2_FALSE);
 	}
 	return AXIS2_SUCCESS;
 }