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 sa...@apache.org on 2006/01/23 11:28:09 UTC

svn commit: r371515 - in /webservices/axis2/trunk/c/modules/core/transport/http: http_transport_utils.c http_worker.c receiver/http_server.c receiver/http_svr_thread.c sender/http_client.c server/http_server_main.c url.c

Author: samisa
Date: Mon Jan 23 02:27:58 2006
New Revision: 371515

URL: http://svn.apache.org/viewcvs?rev=371515&view=rev
Log:
Added Content-Length checking logic. fixed some bugs in comments

Modified:
    webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c
    webservices/axis2/trunk/c/modules/core/transport/http/http_worker.c
    webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_server.c
    webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_svr_thread.c
    webservices/axis2/trunk/c/modules/core/transport/http/sender/http_client.c
    webservices/axis2/trunk/c/modules/core/transport/http/server/http_server_main.c
    webservices/axis2/trunk/c/modules/core/transport/http/url.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=371515&r1=371514&r2=371515&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 Mon Jan 23 02:27:58 2006
@@ -36,7 +36,7 @@
 axis2_http_transport_utils_process_http_post_request
                         (axis2_env_t **env, axis2_msg_ctx_t *msg_ctx, 
                         axis2_stream_t *in_stream, axis2_stream_t *out_stream,
-						axis2_char_t *content_type, 
+						axis2_char_t *content_type, int content_length,
                         axis2_char_t *soap_action_header,
                         axis2_char_t *request_uri);
     
@@ -97,7 +97,7 @@
 axis2_http_transport_utils_process_http_post_request
                         (axis2_env_t **env, axis2_msg_ctx_t *msg_ctx, 
                         axis2_stream_t *in_stream, axis2_stream_t *out_stream,
-						axis2_char_t *content_type, 
+						axis2_char_t *content_type, int content_length, 
                         axis2_char_t *soap_action_header,
                         axis2_char_t *request_uri)
 {
@@ -121,6 +121,9 @@
 	
 	callback_ctx.in_stream = in_stream;
 	callback_ctx.env = *env;
+	callback_ctx.content_length = content_length;
+	callback_ctx.unread_len = content_length;
+	
 	
 	if(NULL != soap_action_header)	
 	{
@@ -212,7 +215,8 @@
     if (!soap_envelope)
         return AXIS2_FAILURE;
     
-    axis2_soap_body_t *soap_body = AXIS2_SOAP_ENVELOPE_GET_BODY(soap_envelope, env);
+    axis2_soap_body_t *soap_body = AXIS2_SOAP_ENVELOPE_GET_BODY(soap_envelope, 
+						env);
     
     if (!soap_body)
         return AXIS2_FAILURE;
@@ -348,8 +352,8 @@
 		axis2_om_element_t *tmp_ele = NULL;
 		axis2_om_node_t *tmp_node = NULL;
 		axis2_hash_this(hi, (const void **)&name, NULL, (void**)&value);
-		tmp_ele = axis2_om_element_create(env, op_node, (axis2_char_t*)name, def_om_ns, 
-						&tmp_node);
+		tmp_ele = axis2_om_element_create(env, op_node, (axis2_char_t*)name,
+						def_om_ns, &tmp_node);
 		AXIS2_OM_ELEMENT_SET_TEXT(tmp_ele, env, (axis2_char_t*)value, tmp_node);
 	}
     return envelope;
@@ -602,7 +606,8 @@
 	{
 		void *fsname = NULL;
 		svcs_exists = AXIS2_TRUE;
-		ret = AXIS2_STRACAT(tmp2, "<hr><h2><font color=\"blue\">Faulty Services</font></h2>"
+		ret = AXIS2_STRACAT(tmp2, "<hr><h2><font color=\"blue\">Faulty \
+						Services</font></h2>"
 							, env);
 		AXIS2_FREE((*env)->allocator, tmp2);
         tmp2 = ret;
@@ -626,8 +631,8 @@
 	{
 		ret = AXIS2_STRDUP("<h2>There are no services deployed</h2>", env);
 	}
-	ret = AXIS2_STRACAT("<html><head><title>Axis2C :: Services</title></head><body>"
-							, tmp2, env);
+	ret = AXIS2_STRACAT("<html><head><title>Axis2C :: Services</title></head>\
+						<body>" , tmp2, env);
 	/*AXIS2_FREE((*env)->allocator, tmp2);*/
     tmp2 = ret;
 	ret = AXIS2_STRACAT(tmp2, "</body></html>\r\n", env);
@@ -663,11 +668,21 @@
 {
 	axis2_stream_t *in_stream = NULL;
 	axis2_env_t **env = NULL;
+	int len = -1;
 	if(NULL == buffer || NULL == ctx)
 	{
 		return 0;
 	}
+	if(((axis2_callback_info_t*)ctx)->unread_len <= 0)
+	{
+		return -1;
+	}
 	in_stream = ((axis2_callback_info_t*)ctx)->in_stream;
 	env = &((axis2_callback_info_t*)ctx)->env;
-	return AXIS2_STREAM_READ(in_stream, env, buffer, size);
+	len = AXIS2_STREAM_READ(in_stream, env, buffer, size);
+	if(len > 0)
+	{
+		((axis2_callback_info_t*)ctx)->unread_len -= len;
+	}
+	return len;
 }

Modified: webservices/axis2/trunk/c/modules/core/transport/http/http_worker.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/http_worker.c?rev=371515&r1=371514&r2=371515&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/http_worker.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/http_worker.c Mon Jan 23 02:27:58 2006
@@ -138,6 +138,7 @@
 	axis2_bool_t processed = AXIS2_FALSE;
 	axis2_char_t *ctx_written = NULL;
 	axis2_status_t status = AXIS2_FAILURE;
+	int content_length = -1;
 	
 	AXIS2_FUNC_PARAM_CHECK(http_worker, env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK((*env)->error, svr_conn, AXIS2_FAILURE);
@@ -152,8 +153,37 @@
 						AXIS2_FAILURE);
 		return AXIS2_FALSE;
 	}
-	request_body = AXIS2_HTTP_SIMPLE_REQUEST_GET_BODY(simple_request, env);
+	
+	content_length = AXIS2_HTTP_SIMPLE_REQUEST_GET_CONTENT_LENGTH(simple_request
+						, env);
+	http_version = AXIS2_HTTP_REQUEST_LINE_GET_HTTP_VERSION
+						(AXIS2_HTTP_SIMPLE_REQUEST_GET_REQUEST_LINE
+						(simple_request, env), env);
+	if(NULL == http_version)
+	{
+		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NULL_HTTP_VERSION, 
+						AXIS2_FAILURE);
+		return AXIS2_FAILURE;
+	}
 	response = axis2_http_simple_response_create_default(env);
+	if(content_length < 0)
+	{
+		if(0 == AXIS2_STRCASECMP(AXIS2_HTTP_REQUEST_LINE_GET_METHOD(
+						AXIS2_HTTP_SIMPLE_REQUEST_GET_REQUEST_LINE(
+						simple_request, env), env), AXIS2_HTTP_HEADER_POST))
+		{
+			AXIS2_HTTP_SIMPLE_RESPONSE_SET_STAUTUS_LINE(response, env, 
+						http_version, 411, "Length Required");
+			status = AXIS2_SIMPLE_HTTP_SVR_CONN_WRITE_RESPONSE(svr_conn, env, 
+						response);
+			AXIS2_HTTP_SIMPLE_RESPONSE_FREE(response, env);
+			response = NULL;
+			return status;
+		}
+		
+	}
+	request_body = AXIS2_HTTP_SIMPLE_REQUEST_GET_BODY(simple_request, env);
+	
 	out_desc = AXIS2_CONF_GET_TRANSPORT_OUT(AXIS2_CONF_CTX_GET_CONF
 						(http_worker_impl->conf_ctx, env), env, 
 						axis2_qname_create(env, AXIS2_TRANSPORT_HTTP, NULL, 
@@ -165,15 +195,7 @@
 	msg_ctx = axis2_msg_ctx_create(env, conf_ctx, in_desc, out_desc);
 	AXIS2_MSG_CTX_SET_SERVER_SIDE(msg_ctx, env, AXIS2_TRUE);
 	
-	http_version = AXIS2_HTTP_REQUEST_LINE_GET_HTTP_VERSION
-						(AXIS2_HTTP_SIMPLE_REQUEST_GET_REQUEST_LINE
-						(simple_request, env), env);
 	
-	if(NULL == http_version)
-	{
-		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NULL_HTTP_VERSION, 
-						AXIS2_FAILURE);
-	}
 	if(0 == AXIS2_STRCASECMP(http_version, AXIS2_HTTP_HEADER_PROTOCOL_11))
 	{
 		axis2_http_worker_set_transport_out_config(http_worker, env, conf_ctx,
@@ -250,7 +272,7 @@
 		status = axis2_http_transport_utils_process_http_post_request
                         (env, msg_ctx, request_body, out_stream,
 						AXIS2_HTTP_SIMPLE_REQUEST_GET_CONTENT_TYPE(
-						simple_request, env) ,soap_action,
+						simple_request, env) , content_length, soap_action,
 						AXIS2_HTTP_REQUEST_LINE_GET_URI
 						(AXIS2_HTTP_SIMPLE_REQUEST_GET_REQUEST_LINE(
 						simple_request, env), env));
@@ -319,8 +341,7 @@
 	AXIS2_MSG_CTX_FREE(msg_ctx, env);
 	msg_ctx = NULL;
 	AXIS2_HTTP_SIMPLE_RESPONSE_FREE(response, env);
-	response = NULL;
-	
+	response = NULL;	
     return status;
 }
 

Modified: webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_server.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_server.c?rev=371515&r1=371514&r2=371515&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_server.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_server.c Mon Jan 23 02:27:58 2006
@@ -40,7 +40,7 @@
 #define AXIS2_INTF_TO_IMPL(http_server) \
                 ((axis2_http_server_impl_t *)(http_server))
 
-/***************************** Function servers *******************************/
+/***************************** Function headers *******************************/
 axis2_status_t AXIS2_CALL 
 axis2_http_server_init(axis2_transport_receiver_t *server, axis2_env_t **env,
 						axis2_conf_ctx_t *conf_ctx, 
@@ -66,7 +66,7 @@
 axis2_status_t AXIS2_CALL 
 axis2_http_server_free (axis2_transport_receiver_t *server, axis2_env_t **env);
 
-/***************************** End of function servers ************************/
+/***************************** End of function headers ************************/
 
 AXIS2_DECLARE(axis2_transport_receiver_t *) 
 axis2_http_server_create (axis2_env_t **env, axis2_char_t *repo, int port)

Modified: webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_svr_thread.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_svr_thread.c?rev=371515&r1=371514&r2=371515&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_svr_thread.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_svr_thread.c Mon Jan 23 02:27:58 2006
@@ -41,7 +41,7 @@
 #define AXIS2_INTF_TO_IMPL(http_svr_thread) \
                 ((axis2_http_svr_thread_impl_t *)(http_svr_thread))
 
-/***************************** Function svr_threads *******************************/
+/***************************** Function headers *******************************/
 axis2_status_t AXIS2_CALL 
 axis2_http_svr_thread_run(axis2_http_svr_thread_t *svr_thread, 
 						axis2_env_t **env);
@@ -62,7 +62,7 @@
 axis2_http_svr_thread_free (axis2_http_svr_thread_t *svr_thread, 
 						axis2_env_t **env);					
 
-/***************************** End of function svr_threads ************************/
+/***************************** End of function headers ************************/
 
 axis2_http_svr_thread_t* AXIS2_CALL
 axis2_http_svr_thread_create (axis2_env_t **env, int port)

Modified: webservices/axis2/trunk/c/modules/core/transport/http/sender/http_client.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/sender/http_client.c?rev=371515&r1=371514&r2=371515&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/http_client.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/http_client.c Mon Jan 23 02:27:58 2006
@@ -44,7 +44,7 @@
 #define AXIS2_INTF_TO_IMPL(http_client) \
                 ((axis2_http_client_impl_t *)(http_client))
 
-/***************************** Function clients *******************************/
+/***************************** Function headers *******************************/
 axis2_status_t AXIS2_CALL 
 axis2_http_client_send (axis2_http_client_t *client, axis2_env_t **env,
 						axis2_http_simple_request_t *request);
@@ -67,7 +67,7 @@
 axis2_status_t AXIS2_CALL 
 axis2_http_client_free (axis2_http_client_t *client, axis2_env_t **env);							
 
-/***************************** End of function clients ************************/
+/***************************** End of function headers ************************/
 
 AXIS2_DECLARE(axis2_http_client_t *) 
 axis2_http_client_create (axis2_env_t **env, axis2_url_t *url)

Modified: webservices/axis2/trunk/c/modules/core/transport/http/server/http_server_main.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/server/http_server_main.c?rev=371515&r1=371514&r2=371515&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/server/http_server_main.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/server/http_server_main.c Mon Jan 23 02:27:58 2006
@@ -21,10 +21,11 @@
 #include <axis2_error_default.h>
 #include <axis2_log_default.h>
 
-/***************************** Function servers *******************************/
+
+/***************************** Function headers *******************************/
 axis2_env_t* init_syetem_env(axis2_allocator_t *allocator);
 void system_exit(axis2_allocator_t *allocator, axis2_env_t *env, int status);
-/***************************** End of function servers ************************/
+/***************************** End of function headers ************************/
 axis2_env_t* init_syetem_env(axis2_allocator_t *allocator)
 {
 	axis2_error_t *error = axis2_error_create(allocator);

Modified: webservices/axis2/trunk/c/modules/core/transport/http/url.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/url.c?rev=371515&r1=371514&r2=371515&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/url.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/url.c Mon Jan 23 02:27:58 2006
@@ -38,7 +38,7 @@
 
 #define AXIS2_INTF_TO_IMPL(url) ((axis2_url_impl_t *)(url))
 
-/***************************** Function urls *******************************/
+/***************************** Function headers *******************************/
 axis2_char_t* AXIS2_CALL 
 axis2_url_to_external_form (axis2_url_t *url, axis2_env_t **env);
 axis2_status_t AXIS2_CALL 
@@ -64,7 +64,7 @@
 axis2_url_open (axis2_url_t *url, axis2_env_t **env);
 axis2_status_t AXIS2_CALL
 axis2_url_close (axis2_url_t *url, axis2_env_t **env);
-/***************************** End of function urls ************************/
+/***************************** End of function headers ************************/
 
 AXIS2_DECLARE(axis2_url_t *) 
 axis2_url_create (axis2_env_t **env, axis2_char_t *protocol,