axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam...@apache.org
Subject svn commit: r369361 [2/3] - in /webservices/axis2/trunk/c/modules/core/transport/http: ./ receiver/ sender/
Date Mon, 16 Jan 2006 05:59:11 GMT
Added: 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=369361&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c Sun Jan 15 21:58:47 2006
@@ -0,0 +1,651 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+#include <axis2_http_transport_utils.h>
+#include <string.h>
+#include <ctype.h>
+#include <axis2_conf.h>
+#include <axis2_op.h>
+#include <axis2_qname.h>
+#include <axis2_http_transport.h>
+#include <axis2_soap_builder.h>
+#include <axis2_engine.h>
+#include <axis2_soap_body.h>
+#include <axis2_utils.h>
+#include <axis2_om_namespace.h>
+#include <axis2_om_node.h>
+#include <axis2_hash.h>
+#include <axis2_soap.h>
+
+/***************************** Function headers *******************************/
+
+axis2_status_t AXIS2_CALL 
+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 *soap_action_header,
+                        axis2_char_t *request_uri);
+    
+axis2_bool_t AXIS2_CALL 
+axis2_http_transport_utils_process_http_get_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 *soap_action_header, 
+                        axis2_char_t *request_uri, axis2_conf_ctx_t *conf_ctx, 
+                        axis2_hash_t *request_params);
+    
+axis2_soap_envelope_t* AXIS2_CALL 
+axis2_http_transport_utils_create_envelope_from_get_request
+                        (axis2_env_t **env, axis2_char_t *request_uri,
+                        axis2_hash_t *request_params);
+    
+axis2_om_stax_builder_t* AXIS2_CALL 
+axis2_http_transport_utils_select_builder_for_mime
+                        (axis2_env_t **env, axis2_char_t *request_uri,
+                        axis2_msg_ctx_t *msg_ctx, axis2_stream_t *in_stream,
+                        axis2_char_t *content_type);
+    
+axis2_bool_t AXIS2_CALL 
+axis2_http_transport_utils_is_optimized(axis2_env_t **env, 
+                                        axis2_om_element_t *om_element);
+                                                
+axis2_bool_t AXIS2_CALL 
+axis2_http_transport_utils_do_write_mtom(axis2_env_t **env, 
+                                        axis2_msg_ctx_t *msg_ctx);
+                                                
+axis2_bool_t AXIS2_CALL 
+axis2_http_transport_utils_is_doing_rest(axis2_env_t **env, 
+                                        axis2_msg_ctx_t *msg_ctx);
+                                                
+axis2_bool_t AXIS2_CALL 
+axis2_http_transport_utils_is_doing_rest_through_post
+                        (axis2_env_t **env, axis2_msg_ctx_t *msg_ctx);
+						
+axis2_status_t AXIS2_CALL
+axis2_http_transport_utils_strdecode(axis2_env_t **env, axis2_char_t *dest, 
+						axis2_char_t *src);
+						
+int AXIS2_CALL
+axis2_http_transport_utils_hexit(axis2_char_t c);
+
+axis2_char_t* AXIS2_CALL
+axis2_http_transport_utils_get_services_html(axis2_env_t **env, 
+							axis2_conf_ctx_t *conf_ctx);
+axis2_char_t* AXIS2_CALL
+axis2_http_transport_utils_get_charset_enc(axis2_env_t **env, 
+						axis2_char_t *content_type);
+int
+axis2_http_transport_utils_on_data_request(char *buffer, int size, void *ctx);						
+/***************************** End of function headers ************************/
+
+axis2_status_t AXIS2_CALL 
+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 *soap_action_header,
+                        axis2_char_t *request_uri)
+{
+	axis2_soap_envelope_t *soap_envelope = NULL;
+	axis2_soap_builder_t *soap_builder = NULL;
+	axis2_om_stax_builder_t *om_builder = NULL;
+	axis2_bool_t is_soap11 = AXIS2_FALSE;
+	axis2_xml_reader_t *xml_reader = NULL;
+	axis2_char_t *char_set = NULL;
+	/*axis2_char_t *xml_char_set = NULL;*/
+	axis2_conf_ctx_t *conf_ctx = NULL;
+	axis2_callback_info_t callback_ctx;
+	
+    AXIS2_PARAM_CHECK((*env)->error, msg_ctx, AXIS2_FAILURE);
+	AXIS2_PARAM_CHECK((*env)->error, in_stream, AXIS2_FAILURE);
+	AXIS2_PARAM_CHECK((*env)->error, out_stream, AXIS2_FAILURE);
+	AXIS2_PARAM_CHECK((*env)->error, content_type, AXIS2_FAILURE);
+	AXIS2_PARAM_CHECK((*env)->error, request_uri, AXIS2_FAILURE);
+	
+	conf_ctx = AXIS2_MSG_CTX_GET_CONF_CTX(msg_ctx, env);
+	
+	callback_ctx.in_stream = in_stream;
+	callback_ctx.env = *env;
+	
+	if(NULL != soap_action_header)	
+	{
+		/* remove leading and trailing " s */
+		if('"' == soap_action_header[0])
+		{
+			memmove(soap_action_header, soap_action_header+sizeof(axis2_char_t),
+						strlen(soap_action_header) + sizeof(axis2_char_t));
+		}
+		if('"' == soap_action_header[strlen(soap_action_header) -1])
+		{
+			soap_action_header[strlen(soap_action_header) -1] = '\0';
+		}
+	}
+	AXIS2_MSG_CTX_SET_WSA_ACTION(msg_ctx, env, soap_action_header);
+	AXIS2_MSG_CTX_SET_SOAP_ACTION(msg_ctx, env, soap_action_header);
+	AXIS2_MSG_CTX_SET_TO(msg_ctx, env, axis2_endpoint_ref_create(env, 
+					request_uri));
+	AXIS2_MSG_CTX_SET_PROPERTY(msg_ctx, env, 
+					AXIS2_TRANSPORT_OUT, out_stream, AXIS2_FALSE);
+	AXIS2_MSG_CTX_SET_SERVER_SIDE(msg_ctx, env, AXIS2_TRUE);
+	
+	xml_reader = axis2_xml_reader_create_for_memory(env, 
+						axis2_http_transport_utils_on_data_request, 
+						(void *)&callback_ctx, NULL);
+	char_set = axis2_http_transport_utils_get_charset_enc(env,content_type);
+	/* TODO set the charset of the stream before (at least default)
+	 *	we read them
+	 */
+	AXIS2_MSG_CTX_SET_PROPERTY(msg_ctx, env, AXIS2_CHARACTER_SET_ENCODING,
+					char_set, AXIS2_TRUE);
+	om_builder = axis2_om_stax_builder_create(env, xml_reader);
+	if(NULL != strstr(content_type, AXIS2_HTTP_HEADER_ACCEPT_APPL_SOAP))
+	{
+		is_soap11 = AXIS2_FALSE;
+		soap_builder = axis2_soap_builder_create(env, om_builder, 
+                    AXIS2_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI);
+		soap_envelope = AXIS2_SOAP_BUILDER_GET_SOAP_ENVELOPE(soap_builder,
+					env);
+	}
+	else if(NULL != strstr(content_type, AXIS2_HTTP_HEADER_ACCEPT_TEXT_XML))
+	{
+		is_soap11 = AXIS2_TRUE;
+		if(NULL != soap_action_header && AXIS2_STRLEN(soap_action_header)
+					> 0)
+		{
+			soap_builder = axis2_soap_builder_create(env, om_builder, 
+						AXIS2_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI);
+			soap_envelope = AXIS2_SOAP_BUILDER_GET_SOAP_ENVELOPE(
+					soap_builder, env);
+		}
+		/* REST support
+		 * else
+		 * {
+		 *		envelope = AXIS2_SOAP_ENVELOPE_GET_DEFAULT_SOAP_ENVELOPE(
+		 *			env);
+		 *		AXIS2_SOAP_BODY_ADD_CHILD(AXIS2_SOAP_ENVELOPE_GET_BODY(
+		 *			envelope, env), AXIS2_OM_STAX_BUILDER_GET_DOCUMENT(
+		 *			om_builder, env));
+		 */			
+	}
+	/* xml_char_set = AXIS2_OM_DOCUMENT_GET_CHARSET_ENC(
+	 *					AXIS2_OM_STAX_BUILDER_GET_DOCUMENT(env om_builder),
+	 *					env);
+	 *
+	 *if(0 != AXIS2_STRCMP(char_set, xml_char_set))
+	 *{
+	 *	AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_CHARSET_MISMATCH, 
+	 *					AXIS2_FAILURE);
+	 *	AXIS2_SOAP_ENVELOPE_FREE(envelope, env);
+	 *	envelope = NULL;
+	 *	AXIS2_XML_READER_FREE(xml_reader, env);
+	 *	xml_reader = NULL;
+	 *	AXIS2_OM_STAX_BUILDER_FREE(om_builder, env);
+	 *	om_builder = NULL;
+	 *	if(NULL != soap_builder)
+	 *	{
+	 *	 	AXIS2_SOAP_BUILDER_FREE(soap_builder, env);
+	 *	 	soap_builder = NULL;
+	 *	}
+	 *	return AXIS2_FAILURE;
+	 *}
+	 */
+	
+	AXIS2_MSG_CTX_SET_SOAP_ENVELOPE(msg_ctx, env, soap_envelope);
+	axis2_engine_t *engine = NULL;
+	engine = axis2_engine_create(env, conf_ctx);
+	if(AXIS2_TRUE == AXIS2_SOAP_BODY_HAS_FAULT(AXIS2_SOAP_ENVELOPE_GET_BODY(
+						soap_envelope, env), env))
+	{
+		AXIS2_ENGINE_RECEIVE_FAULT(engine, env, msg_ctx);
+	}
+	else
+	{
+		AXIS2_ENGINE_RECEIVE(engine, env, msg_ctx);
+	}
+	if(NULL == AXIS2_MSG_CTX_GET_SOAP_ENVELOPE(msg_ctx, env) && 
+						AXIS2_FALSE == is_soap11)
+	{
+		axis2_soap_envelope_t *def_envelope = axis2_soap_envelope_create_null
+						(env);
+		AXIS2_MSG_CTX_SET_SOAP_ENVELOPE(msg_ctx, env, def_envelope);
+	}
+	return AXIS2_SUCCESS;
+}
+
+
+axis2_bool_t AXIS2_CALL 
+axis2_http_transport_utils_process_http_get_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 *soap_action_header, 
+                        axis2_char_t *request_uri, axis2_conf_ctx_t *conf_ctx, 
+                        axis2_hash_t *request_params)
+{
+	axis2_soap_envelope_t *soap_envelope = NULL;
+	axis2_engine_t *engine = NULL;
+		
+	AXIS2_PARAM_CHECK((*env)->error, msg_ctx, AXIS2_FALSE);
+	AXIS2_PARAM_CHECK((*env)->error, in_stream, AXIS2_FALSE);
+	AXIS2_PARAM_CHECK((*env)->error, out_stream, AXIS2_FALSE);
+	AXIS2_PARAM_CHECK((*env)->error, content_type, AXIS2_FALSE);
+	AXIS2_PARAM_CHECK((*env)->error, request_uri, AXIS2_FALSE);
+	AXIS2_PARAM_CHECK((*env)->error, request_params, AXIS2_FALSE);
+	
+	if(NULL != soap_action_header)	
+	{
+		/* remove leading and trailing " s */
+		if('"' == soap_action_header[0])
+		{
+			memmove(soap_action_header, soap_action_header+sizeof(axis2_char_t),
+						strlen(soap_action_header) + sizeof(axis2_char_t));
+		}
+		if('"' == soap_action_header[strlen(soap_action_header) -1])
+		{
+			soap_action_header[strlen(soap_action_header) -1] = '\0';
+		}
+	}
+	AXIS2_MSG_CTX_SET_WSA_ACTION(msg_ctx, env, soap_action_header);
+	AXIS2_MSG_CTX_SET_SOAP_ACTION(msg_ctx, env, soap_action_header);
+	AXIS2_MSG_CTX_SET_TO(msg_ctx, env, axis2_endpoint_ref_create(env, 
+					request_uri));
+	AXIS2_MSG_CTX_SET_PROPERTY(msg_ctx, env, 
+					AXIS2_TRANSPORT_OUT, out_stream, AXIS2_FALSE);
+	AXIS2_MSG_CTX_SET_SERVER_SIDE(msg_ctx, env, AXIS2_TRUE);
+	
+	soap_envelope = axis2_http_transport_utils_create_envelope_from_get_request(
+					env, request_uri, request_params);
+	if(NULL == soap_envelope)
+	{
+		return AXIS2_FALSE;
+	}
+	else
+	{
+		AXIS2_MSG_CTX_SET_DOING_REST(msg_ctx, env, AXIS2_TRUE);
+		AXIS2_MSG_CTX_SET_SOAP_ENVELOPE(msg_ctx, env, soap_envelope);
+		engine = axis2_engine_create(env, conf_ctx);
+		AXIS2_ENGINE_RECEIVE(engine, env, msg_ctx);
+		return AXIS2_TRUE;
+	}
+    return AXIS2_FALSE;
+}
+
+
+axis2_soap_envelope_t* AXIS2_CALL 
+axis2_http_transport_utils_create_envelope_from_get_request
+                        (axis2_env_t **env, axis2_char_t *request_uri,
+                        axis2_hash_t *request_params)
+{
+	axis2_char_t **values = NULL;
+	axis2_soap_envelope_t *envelope = NULL;
+	axis2_om_namespace_t *om_ns = NULL;
+	axis2_om_namespace_t *def_om_ns = NULL;
+	axis2_om_node_t *document_node = NULL;
+	axis2_om_node_t *op_node = NULL;
+	axis2_om_element_t *op_ele = NULL;
+	axis2_hash_index_t *hi = NULL;
+	AXIS2_PARAM_CHECK((*env)->error, request_uri, NULL);
+	AXIS2_PARAM_CHECK((*env)->error, request_params, NULL);
+	
+	values = axis2_parse_request_url_for_svc_and_op(env, request_uri);
+	if(NULL == values)
+	{
+		return NULL;
+	}
+	if(NULL == values[0] && NULL != values[1])
+	{
+		AXIS2_FREE((*env)->allocator, values[1]);
+		AXIS2_FREE((*env)->allocator, values);
+		return NULL;
+	}
+	if(NULL != values[0] && NULL == values[1])
+	{
+		AXIS2_FREE((*env)->allocator, values[0]);
+		AXIS2_FREE((*env)->allocator, values);
+		return NULL;
+	}
+	if(NULL == values[0] && NULL == values[1])
+	{
+		AXIS2_FREE((*env)->allocator, values);
+		return NULL;
+	}
+	envelope = axis2_soap_envelope_create_null(env);
+	om_ns = axis2_om_namespace_create(env, values[0], "services");
+	def_om_ns = axis2_om_namespace_create(env, "", NULL);
+	document_node = AXIS2_SOAP_BODY_GET_BASE_NODE(AXIS2_SOAP_ENVELOPE_GET_BODY(
+						envelope, env), env);
+	op_ele = axis2_om_element_create(env, document_node, values[1], om_ns, 
+						&op_node);
+	
+	for(hi = axis2_hash_first(request_params, env); NULL != hi; 
+						axis2_hash_next(env, hi))
+	{
+		void *name = NULL;
+		void *value = NULL;
+		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);
+		AXIS2_OM_ELEMENT_SET_TEXT(tmp_ele, env, (axis2_char_t*)value, tmp_node);
+	}
+    return envelope;
+}
+
+
+axis2_om_stax_builder_t* AXIS2_CALL 
+axis2_http_transport_utils_select_builder_for_mime
+                        (axis2_env_t **env, axis2_char_t *request_uri,
+                        axis2_msg_ctx_t *msg_ctx, axis2_stream_t *in_stream,
+                        axis2_char_t *content_type)
+{
+	/*
+        TODO implement when MTOM support is added
+    */
+    return NULL;
+}
+
+
+axis2_bool_t AXIS2_CALL 
+axis2_http_transport_utils_is_optimized(axis2_env_t **env, 
+                                        axis2_om_element_t *om_element)
+{
+	/*
+        TODO implement when MTOM support is added
+    */
+    return AXIS2_FALSE;
+}
+
+
+axis2_bool_t AXIS2_CALL 
+axis2_http_transport_utils_do_write_mtom(axis2_env_t **env, 
+                                        axis2_msg_ctx_t *msg_ctx)
+{
+   /*
+        TODO implement when MTOM support is added
+    */
+    return AXIS2_FALSE;
+}
+
+
+axis2_bool_t AXIS2_CALL 
+axis2_http_transport_utils_is_doing_rest(axis2_env_t **env, 
+                                        axis2_msg_ctx_t *msg_ctx)
+{
+    /*
+        TODO implement when REST support is added
+    */
+    return AXIS2_FALSE;
+}
+
+
+axis2_bool_t AXIS2_CALL 
+axis2_http_transport_utils_is_doing_rest_through_post
+                        (axis2_env_t **env, axis2_msg_ctx_t *msg_ctx)
+{
+    /*
+        TODO implement when REST support is added
+    */
+    return AXIS2_FALSE;
+}
+
+axis2_hash_t *AXIS2_CALL
+axis2_http_transport_utils_get_request_params(axis2_env_t **env, 
+						axis2_char_t *request_uri)
+{
+	
+	
+	axis2_char_t *query_str = NULL;
+	axis2_char_t *tmp = strchr(request_uri, '?');
+	axis2_char_t *tmp2 = NULL;
+	axis2_char_t *tmp_name = NULL;
+	axis2_char_t *tmp_value = NULL;
+	axis2_hash_t *ret = NULL;
+	
+	AXIS2_PARAM_CHECK((*env)->error, request_uri, AXIS2_FAILURE);
+	
+	if(NULL == tmp || '\0' == *(tmp +1))
+	{
+		return NULL;
+	}
+	query_str = AXIS2_STRDUP(tmp+1, env);
+		
+	for(tmp2 = tmp = query_str; *tmp != '\0'; ++tmp)
+	{
+		if('=' == *tmp)
+		{
+			*tmp = '\0';
+			tmp_name = AXIS2_STRDUP(tmp2, env);
+			axis2_http_transport_utils_strdecode(env, tmp_name, tmp_name);
+			tmp2 = tmp +1;			
+		}
+		if('&' == *tmp)
+		{
+			*tmp = '\0';
+			tmp_value = AXIS2_STRDUP(tmp2, env);
+			axis2_http_transport_utils_strdecode(env, tmp_value, tmp_value);
+			tmp2 = tmp +1;
+		}
+		if(NULL != tmp_name && NULL != tmp_value)
+		{
+			if(NULL == ret)
+			{
+				ret = axis2_hash_make(env);
+			}
+			axis2_hash_set(ret, tmp_name, AXIS2_HASH_KEY_STRING, tmp_value);
+			tmp_name = NULL;
+			tmp_value = NULL;
+		}
+	}
+	if(NULL != tmp_name && '\0' != *tmp2)
+	{
+		if(NULL == ret)
+		{
+			ret = axis2_hash_make(env);
+		}
+		tmp_value = AXIS2_STRDUP(tmp2, env);
+		axis2_http_transport_utils_strdecode(env, tmp_value, tmp_value);
+		axis2_hash_set(ret, tmp_name, AXIS2_HASH_KEY_STRING, tmp_value);
+	}
+	
+	return ret;
+}
+
+
+axis2_status_t AXIS2_CALL
+axis2_http_transport_utils_strdecode(axis2_env_t **env, axis2_char_t *dest, 
+						axis2_char_t *src)
+{
+	AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+	AXIS2_PARAM_CHECK((*env)->error, dest, AXIS2_FAILURE);
+	AXIS2_PARAM_CHECK((*env)->error, src, AXIS2_FAILURE);
+
+    for ( ; *src != '\0'; ++dest, ++src )
+    {
+		if ( src[0] == '%' && isxdigit( src[1] ) && isxdigit( src[2] ) )
+		{
+			*dest = axis2_http_transport_utils_hexit( src[1] ) * 16 + 
+							axis2_http_transport_utils_hexit( src[2] );
+			src += 2;
+		}
+		else
+		{
+			*dest = *src;
+		}
+    }
+    *dest = '\0';
+	
+	return AXIS2_SUCCESS;
+}
+
+
+int AXIS2_CALL
+axis2_http_transport_utils_hexit(axis2_char_t c)
+{
+	if ( c >= '0' && c <= '9' )
+	{
+		return c - '0';
+	}
+	if ( c >= 'a' && c <= 'f' )
+	{
+		return c - 'a' + 10;
+	}
+	if ( c >= 'A' && c <= 'F' )
+	{
+		return c - 'A' + 10;
+	}
+	return 0;           /* shouldn't happen, we're guarded by isxdigit() */
+}
+
+axis2_char_t* AXIS2_CALL
+axis2_http_transport_utils_get_services_html(axis2_env_t **env, 
+							axis2_conf_ctx_t *conf_ctx)
+{
+	axis2_hash_t *services_map = NULL;
+	axis2_hash_t *errorneous_svc_map = NULL;
+	axis2_char_t *tmp = NULL;
+	axis2_char_t *tmp2 = "<h2>Deployed Services</h2>";
+	axis2_hash_index_t *hi = NULL;
+	axis2_bool_t svcs_exists = AXIS2_FALSE;
+	
+	AXIS2_ENV_CHECK(env, NULL);
+	AXIS2_PARAM_CHECK((*env)->error, conf_ctx, NULL);
+	
+	services_map = AXIS2_CONF_GET_SVCS(AXIS2_CONF_CTX_GET_CONF(conf_ctx,env),
+							env);
+	errorneous_svc_map = AXIS2_CONF_GET_FAULTY_SVCS(AXIS2_CONF_CTX_GET_CONF(
+							conf_ctx,env), env);
+	if(NULL != services_map && 0 != axis2_hash_count(services_map))
+	{
+		void *service = NULL;
+		axis2_char_t *sname = NULL;
+		axis2_hash_t *ops = NULL;
+		svcs_exists = AXIS2_TRUE;
+		
+		for (hi = axis2_hash_first (services_map, env);
+             				NULL != hi; hi = axis2_hash_next (env, hi))
+		{
+			axis2_hash_this(hi, NULL, NULL, &service);
+			sname= AXIS2_QNAME_GET_LOCALPART(AXIS2_SVC_GET_QNAME(
+							((axis2_svc_t *)service), env), env);
+			tmp = AXIS2_STRACAT(tmp2, "<h3>", env);
+			tmp2 = AXIS2_STRACAT(tmp, sname, env);
+			AXIS2_FREE((*env)->allocator, tmp);
+			tmp  = AXIS2_STRACAT(tmp2, "</h3>", env);
+			AXIS2_FREE((*env)->allocator, tmp2);
+			ops = AXIS2_SVC_GET_OPS(((axis2_svc_t *)service), env);
+			if(NULL != ops && 0 != axis2_hash_count(ops))
+			{
+				axis2_hash_index_t *hi2 = NULL;
+				void *op = NULL;
+				axis2_char_t *oname = NULL;
+				
+				tmp2 = AXIS2_STRACAT(tmp, "Available Operations <ul>", env);
+				AXIS2_FREE((*env)->allocator, tmp);
+				for(hi2 = axis2_hash_first(ops, env); NULL != hi2;
+							axis2_hash_next(env, hi2))
+				{
+					axis2_hash_this(hi2, NULL, NULL, &op);
+					oname = AXIS2_QNAME_GET_LOCALPART(AXIS2_OP_GET_QNAME(
+							((axis2_op_t *)op), env), env);
+					tmp = AXIS2_STRACAT(tmp2, "<li>", env);
+					AXIS2_FREE((*env)->allocator, tmp2);
+					tmp2 = AXIS2_STRACAT(tmp, oname, env);
+					AXIS2_FREE((*env)->allocator, tmp);
+					tmp = AXIS2_STRACAT(tmp2, "</li>", env);
+					AXIS2_FREE((*env)->allocator, tmp2);
+					tmp2 = tmp;
+				}
+				tmp2 = AXIS2_STRACAT(tmp, "</ul>", env);
+				AXIS2_FREE((*env)->allocator, tmp);
+			}
+			else
+			{
+				tmp2 = AXIS2_STRACAT(tmp, "No operations Available", env);
+				AXIS2_FREE((*env)->allocator, tmp);
+			}			
+		}
+	}
+	if(NULL != errorneous_svc_map && 0 != axis2_hash_count(errorneous_svc_map))
+	{
+		void *fsname = NULL;
+		svcs_exists = AXIS2_TRUE;
+		tmp = AXIS2_STRACAT(tmp2, "<hr><h2><font color=\"blue\">Faulty Services</font></h2>"
+							, env);
+		AXIS2_FREE((*env)->allocator, tmp2);
+		
+		for(hi = axis2_hash_first(errorneous_svc_map, env); NULL != hi;
+							axis2_hash_next(env, hi))
+		{
+			axis2_hash_this(hi, (const void **)&fsname, NULL, NULL);
+			tmp2 = AXIS2_STRACAT(tmp, "<h3><font color=\"blue\">", env);
+			AXIS2_FREE((*env)->allocator, tmp);
+			tmp = AXIS2_STRACAT(tmp2, (axis2_char_t*)fsname, env);
+			AXIS2_FREE((*env)->allocator, tmp2);
+			tmp2 = AXIS2_STRACAT(tmp, "</font></h3>", env);
+			AXIS2_FREE((*env)->allocator, tmp);
+		}
+	}
+	if(AXIS2_FALSE == svcs_exists)
+	{
+		tmp2 = AXIS2_STRDUP("<h2>There are no services deployed</h2>", env);
+	}
+	tmp = AXIS2_STRACAT("<html><head><title>Axis2:Services</title></head><body>"
+							, tmp2, env);
+	AXIS2_FREE((*env)->allocator, tmp2);
+	tmp2 = AXIS2_STRACAT(tmp, "</body></html>", env);
+	AXIS2_FREE((*env)->allocator, tmp);
+	
+	return tmp2;
+}
+
+axis2_char_t* AXIS2_CALL
+axis2_http_transport_utils_get_charset_enc(axis2_env_t **env, 
+						axis2_char_t *content_type)
+{
+	axis2_char_t *tmp = NULL;
+		
+	AXIS2_ENV_CHECK(env, NULL);
+	AXIS2_PARAM_CHECK((*env)->error, content_type, NULL);
+	
+	tmp = strstr(content_type, AXIS2_HTTP_CHAR_SET_ENCODING);
+	if(NULL == tmp)
+	{
+		return AXIS2_STRDUP(AXIS2_HTTP_HEADER_DEFAULT_CHAR_ENCODING, env);
+	}
+	tmp = strchr(tmp, '=');
+	if(NULL == tmp)
+	{
+		return AXIS2_STRDUP(AXIS2_HTTP_HEADER_DEFAULT_CHAR_ENCODING, env);
+	}
+	return AXIS2_STRDUP(tmp, env);
+}
+
+int
+axis2_http_transport_utils_on_data_request(char *buffer, int size, void *ctx)
+{
+	axis2_stream_t *in_stream = NULL;
+	axis2_env_t **env = NULL;
+	if(NULL == buffer || NULL == ctx)
+	{
+		return 0;
+	}
+	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);
+}

Added: 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=369361&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/http_worker.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/http_worker.c Sun Jan 15 21:58:47 2006
@@ -0,0 +1,383 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+#include <axis2_http_worker.h>
+#include <axis2_string.h>
+#include <axis2_http_transport.h>
+#include <axis2_conf.h>
+#include <axis2_string.h>
+#include <axis2_msg_ctx.h>
+#include <axis2_http_request_line.h>
+#include <axis2_http_out_transport_info.h>
+#include <axis2_http_transport_utils.h>
+#include <axis2_op_ctx.h>
+
+/** 
+ * @brief HTTP Worker struct impl
+ *	Axis2 HTTP Worker impl  
+ */
+typedef struct axis2_http_worker_impl axis2_http_worker_impl_t;  
+  
+struct axis2_http_worker_impl
+{
+	axis2_http_worker_t http_worker;
+	axis2_conf_ctx_t *conf_ctx;
+};
+
+#define AXIS2_INTF_TO_IMPL(http_worker) ((axis2_http_worker_impl_t *)\
+                                                                (http_worker))
+
+/***************************** Function headers *******************************/
+
+axis2_bool_t AXIS2_CALL 
+axis2_http_worker_process_request(axis2_http_worker_t *http_worker, 
+							axis2_env_t **env, 
+							axis2_simple_http_svr_conn_t *svr_conn, 
+							axis2_http_simple_request_t *simple_request);
+    
+axis2_status_t AXIS2_CALL 
+axis2_http_worker_set_response_headers(axis2_http_worker_t *http_worker, 
+							axis2_env_t **env, 
+							axis2_simple_http_svr_conn_t *svr_conn, 
+							axis2_http_simple_request_t *simple_request,
+							axis2_http_simple_response_t *simple_response,
+							axis2_ssize_t content_length);
+
+axis2_status_t AXIS2_CALL 
+axis2_http_worker_set_transport_out_config(axis2_http_worker_t *http_worker, 
+							axis2_env_t **env, 
+							axis2_conf_ctx_t *conf_ctx, 
+							axis2_http_simple_response_t *simple_response);
+							
+axis2_hash_t* AXIS2_CALL
+axis2_http_worker_get_headers(axis2_http_worker_t *http_worker, 
+							axis2_env_t **env, 
+							axis2_http_simple_request_t *request);
+	
+axis2_status_t AXIS2_CALL 
+axis2_http_worker_free(axis2_http_worker_t *http_worker, 
+							axis2_env_t **env);
+								
+/***************************** End of function headers ************************/
+
+axis2_http_worker_t * AXIS2_CALL 
+axis2_http_worker_create (axis2_env_t **env, axis2_conf_ctx_t *conf_ctx)
+{
+    AXIS2_ENV_CHECK(env, NULL);
+    axis2_http_worker_impl_t *http_worker_impl = (axis2_http_worker_impl_t *)
+        AXIS2_MALLOC ((*env)->allocator, sizeof(axis2_http_worker_impl_t));
+	
+    if(NULL == http_worker_impl)
+	{
+		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    http_worker_impl->conf_ctx = conf_ctx;
+    
+    http_worker_impl->http_worker.ops = AXIS2_MALLOC((*env)->allocator,
+        sizeof(axis2_http_worker_ops_t));
+    if(NULL == http_worker_impl->http_worker.ops)
+	{
+		axis2_http_worker_free((axis2_http_worker_t*)http_worker_impl, env);
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    
+    http_worker_impl->http_worker.ops->process_request = 
+                                    axis2_http_worker_process_request;
+    http_worker_impl->http_worker.ops->free = axis2_http_worker_free;
+    
+	return &(http_worker_impl->http_worker);
+}
+
+axis2_status_t AXIS2_CALL
+axis2_http_worker_free (axis2_http_worker_t *http_worker, axis2_env_t **env)
+{
+	AXIS2_FUNC_PARAM_CHECK(http_worker, env, AXIS2_FAILURE);
+    
+    AXIS2_INTF_TO_IMPL(http_worker)->conf_ctx = NULL;
+    
+    if(NULL != http_worker->ops)
+        AXIS2_FREE((*env)->allocator, http_worker->ops);
+    
+	AXIS2_FREE((*env)->allocator, AXIS2_INTF_TO_IMPL(http_worker));
+    
+	return AXIS2_SUCCESS;
+}
+
+axis2_bool_t AXIS2_CALL 
+axis2_http_worker_process_request(axis2_http_worker_t *http_worker, 
+						axis2_env_t **env, 
+						axis2_simple_http_svr_conn_t *svr_conn, 
+						axis2_http_simple_request_t *simple_request)
+{
+    axis2_http_worker_impl_t *http_worker_impl = NULL;
+	axis2_conf_ctx_t *conf_ctx = http_worker_impl->conf_ctx;
+	axis2_msg_ctx_t *msg_ctx = NULL;
+	axis2_stream_t *request_body = NULL;
+	axis2_stream_t *out_stream = axis2_stream_create_basic(env);
+	axis2_http_simple_response_t *response = NULL;
+	axis2_transport_out_desc_t *out_desc = NULL;
+	axis2_transport_in_desc_t *in_desc = NULL;
+	axis2_char_t *http_version = NULL;
+	axis2_char_t *soap_action = NULL;
+	axis2_bool_t processed = AXIS2_FALSE;
+	axis2_char_t *ctx_written = NULL;
+	axis2_status_t status = AXIS2_FAILURE;
+	
+	AXIS2_FUNC_PARAM_CHECK(http_worker, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, svr_conn, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, simple_request, AXIS2_FAILURE);
+	
+	http_worker_impl = AXIS2_INTF_TO_IMPL(http_worker);
+	
+	if(NULL != conf_ctx)
+	{
+		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NULL_CONFIGURATION_CONTEXT,
+						AXIS2_FAILURE);
+	}
+	request_body = AXIS2_HTTP_SIMPLE_REQUEST_GET_BODY(simple_request, env);
+	response = axis2_http_simple_response_create_default(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, 
+						NULL));
+	in_desc = AXIS2_CONF_GET_TRANSPORT_IN(AXIS2_CONF_CTX_GET_CONF
+						(http_worker_impl->conf_ctx, env), env, 
+						axis2_qname_create(env, AXIS2_TRANSPORT_HTTP, NULL,
+						NULL));
+	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,
+						response);
+	}
+	AXIS2_MSG_CTX_SET_PROPERTY(msg_ctx, env, AXIS2_TRANSPORT_OUT, out_stream, 
+						AXIS2_FALSE);
+	AXIS2_MSG_CTX_SET_PROPERTY(msg_ctx, env, AXIS2_TRANSPORT_HEADERS, 
+						axis2_http_worker_get_headers(http_worker, env, 
+						simple_request), AXIS2_FALSE);
+	/*
+	 * TODO uuidgen
+	 * AXIS2_MSG_CTX_SET_SVC_GRP_CTX_ID(uuid, env);
+	 */
+	AXIS2_MSG_CTX_SET_PROPERTY(msg_ctx, env, AXIS2_HTTP_OUT_TRANSPORT_INFO,
+						axis2_http_out_transport_info_create(env, response), 
+						AXIS2_FALSE);
+	if(NULL != AXIS2_HTTP_SIMPLE_REQUEST_GET_FIRST_HEADER(simple_request, env, 
+						AXIS2_HTTP_HEADER_SOAP_ACTION))
+	{
+		soap_action = AXIS2_HTTP_HEADER_GET_VALUE(
+						AXIS2_HTTP_SIMPLE_REQUEST_GET_FIRST_HEADER(
+						simple_request, env, AXIS2_HTTP_HEADER_SOAP_ACTION), 
+						env);
+	}
+	if(0 == AXIS2_STRCASECMP(AXIS2_HTTP_REQUEST_LINE_GET_METHOD(
+						AXIS2_HTTP_SIMPLE_REQUEST_GET_REQUEST_LINE(
+						simple_request, env), env), AXIS2_HTTP_HEADER_GET))
+	{
+		processed = axis2_http_transport_utils_process_http_get_request
+                        (env, msg_ctx, request_body, out_stream,
+						AXIS2_HTTP_SIMPLE_REQUEST_GET_CONTENT_TYPE(
+						simple_request, env) ,soap_action,
+						AXIS2_HTTP_REQUEST_LINE_GET_URI(
+						AXIS2_HTTP_SIMPLE_REQUEST_GET_REQUEST_LINE(
+						simple_request, env), env),
+                        conf_ctx, 
+                        axis2_http_transport_utils_get_request_params(env,
+						AXIS2_HTTP_REQUEST_LINE_GET_URI(
+						AXIS2_HTTP_SIMPLE_REQUEST_GET_REQUEST_LINE(
+						simple_request, env), env)));
+		if(AXIS2_FALSE == processed)
+		{
+			AXIS2_HTTP_SIMPLE_RESPONSE_SET_STAUTUS_LINE(response, env,
+						http_version, AXIS2_HTTP_RESPONSE_OK_CODE_VAL, "OK");
+			AXIS2_HTTP_SIMPLE_RESPONSE_SET_BODY_STRING(response, env, 
+						axis2_http_transport_utils_get_services_html(env, 
+						conf_ctx));
+			axis2_http_worker_set_response_headers(http_worker, env, svr_conn,
+						simple_request, response, 0);
+			AXIS2_SIMPLE_HTTP_SVR_CONN_WRITE_RESPONSE(svr_conn, env, response);
+			AXIS2_HTTP_SIMPLE_RESPONSE_FREE(response, env);
+			return AXIS2_TRUE;			
+		}
+		
+	}
+	else 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))
+	{
+		processed = 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,
+						AXIS2_HTTP_REQUEST_LINE_GET_URI
+						(AXIS2_HTTP_SIMPLE_REQUEST_GET_REQUEST_LINE(
+						simple_request, env), env));
+	}
+	axis2_op_ctx_t *op_ctx = AXIS2_MSG_CTX_GET_OP_CTX(msg_ctx, env);
+	if(NULL != op_ctx)
+	{
+		ctx_written = AXIS2_OP_CTX_GET_PROPERTY(op_ctx, env, 
+						AXIS2_RESPONSE_WRITTEN);
+	}
+	if(NULL != ctx_written && AXIS2_STRCASECMP(ctx_written, "TRUE"))
+	{
+		AXIS2_HTTP_SIMPLE_RESPONSE_SET_STAUTUS_LINE(response, env, http_version,
+						AXIS2_HTTP_RESPONSE_OK_CODE_VAL, "OK");
+	}
+	else
+	{
+		AXIS2_HTTP_SIMPLE_RESPONSE_SET_STAUTUS_LINE(response, env, http_version,
+						AXIS2_HTTP_RESPONSE_ACK_CODE_VAL, "Accepted");
+	}
+	AXIS2_HTTP_SIMPLE_RESPONSE_SET_BODY_STREAM(response, env, out_stream);
+	axis2_http_worker_set_response_headers(http_worker, env, svr_conn, 
+						simple_request, response, AXIS2_STREAM_BASIC_GET_LEN(
+						out_stream, env));
+	
+	status = AXIS2_SIMPLE_HTTP_SVR_CONN_WRITE_RESPONSE(svr_conn, env, response);
+	AXIS2_MSG_CTX_FREE(msg_ctx, env);
+	msg_ctx = NULL;
+	AXIS2_HTTP_SIMPLE_RESPONSE_FREE(response, env);
+	response = NULL;
+	
+    return status;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_worker_set_response_headers(axis2_http_worker_t *http_worker, 
+						axis2_env_t **env, 
+						axis2_simple_http_svr_conn_t *svr_conn, 
+						axis2_http_simple_request_t *simple_request,
+						axis2_http_simple_response_t *simple_response,
+						axis2_ssize_t content_length)
+{
+    axis2_http_header_t *conn_header = NULL;
+	
+	AXIS2_FUNC_PARAM_CHECK(http_worker, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, svr_conn, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, simple_request, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, simple_response, AXIS2_FAILURE);
+    if(AXIS2_FALSE == AXIS2_HTTP_SIMPLE_RESPONSE_CONTAINS_HEADER
+                    (simple_response, env, AXIS2_HTTP_HEADER_CONNECTION))
+    {
+        conn_header = AXIS2_HTTP_SIMPLE_REQUEST_GET_FIRST_HEADER(simple_request,
+                    env, AXIS2_HTTP_HEADER_CONNECTION);
+        if(NULL != conn_header)
+        {
+            if(0 == AXIS2_STRCASECMP(AXIS2_HTTP_HEADER_GET_VALUE(conn_header, 
+                    env), AXIS2_HTTP_HEADER_CONNECTION_KEEPALIVE))
+            {
+                axis2_http_header_t *header = axis2_http_header_create(env,
+                    AXIS2_HTTP_HEADER_CONNECTION, 
+                    AXIS2_HTTP_HEADER_CONNECTION_KEEPALIVE);
+                AXIS2_HTTP_SIMPLE_RESPONSE_SET_HEADER(simple_response, env, 
+                    header);
+                AXIS2_SIMPLE_HTTP_SVR_CONN_SET_KEEP_ALIVE(svr_conn, env, 
+                    AXIS2_TRUE);
+            }
+            if(0 == AXIS2_STRCASECMP(AXIS2_HTTP_HEADER_GET_VALUE(conn_header, 
+                    env), AXIS2_HTTP_HEADER_CONNECTION_CLOSE))
+            {
+                axis2_http_header_t *header = axis2_http_header_create(env,
+                    AXIS2_HTTP_HEADER_CONNECTION,
+					AXIS2_HTTP_HEADER_CONNECTION_CLOSE);
+                AXIS2_HTTP_SIMPLE_RESPONSE_SET_HEADER(simple_response, env, 
+                    header);
+                AXIS2_SIMPLE_HTTP_SVR_CONN_SET_KEEP_ALIVE(svr_conn, env, 
+                    AXIS2_FALSE);
+            }
+        }
+        else
+        {
+            if(AXIS2_STRCASECMP(AXIS2_HTTP_SIMPLE_RESPONSE_GET_HTTP_VERSION(
+                    simple_response, env), AXIS2_HTTP_HEADER_PROTOCOL_11))
+            {
+                AXIS2_SIMPLE_HTTP_SVR_CONN_SET_KEEP_ALIVE(svr_conn, env, 
+                    AXIS2_TRUE);               
+            }
+            else
+            {
+                AXIS2_SIMPLE_HTTP_SVR_CONN_SET_KEEP_ALIVE(svr_conn, env, 
+                    AXIS2_FALSE);
+            }
+        }
+        if(AXIS2_TRUE == AXIS2_HTTP_SIMPLE_RESPONSE_CONTAINS_HEADER(
+                    simple_response, env, AXIS2_HTTP_HEADER_TRANSFER_ENCODING))
+        {
+            if(0 != content_length)
+            {
+                axis2_char_t content_len_str[10];
+				axis2_http_header_t *content_len_hdr = NULL;
+				
+                sprintf(content_len_str, "%10d", content_length);
+                content_len_hdr = axis2_http_header_create(
+                    env, AXIS2_HTTP_HEADER_CONTENT_LENGTH, content_len_str);
+                AXIS2_HTTP_SIMPLE_RESPONSE_SET_HEADER(simple_response, env,
+                    content_len_hdr);
+            }
+        }
+    }
+    return AXIS2_SUCCESS;
+}
+
+/*
+ * This is only called for HTTP/1.1 to enable 1.1 specific parameters.
+ *
+ */
+axis2_status_t AXIS2_CALL 
+axis2_http_worker_set_transport_out_config(axis2_http_worker_t *http_worker, 
+						axis2_env_t **env, 
+						axis2_conf_ctx_t *conf_ctx, 
+						axis2_http_simple_response_t *simple_response)
+{
+    axis2_conf_t *config = NULL;
+	axis2_hash_t *tranport_outs = NULL;
+	
+	AXIS2_FUNC_PARAM_CHECK(http_worker, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, conf_ctx, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, simple_response, AXIS2_FAILURE);
+	
+	config = AXIS2_CONF_CTX_GET_CONF(conf_ctx, env);
+    tranport_outs = AXIS2_CONF_GET_TRANSPORTS_OUT(config, env);
+	
+
+    /*
+        TODO implement the method
+    */
+    return AXIS2_SUCCESS;
+}
+
+axis2_hash_t* AXIS2_CALL
+axis2_http_worker_get_headers(axis2_http_worker_t *http_worker, 
+						axis2_env_t **env, axis2_http_simple_request_t *request)
+{
+	/* TODO implement */
+	return NULL;
+}

Added: webservices/axis2/trunk/c/modules/core/transport/http/receiver/Makefile.am
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/receiver/Makefile.am?rev=369361&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/receiver/Makefile.am (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/receiver/Makefile.am Sun Jan 15 21:58:47 2006
@@ -0,0 +1,16 @@
+lib_LTLIBRARIES = libaxis2_http_receiver.la
+AM_CPPFLAGS = $(CPPFLAGS)
+libaxis2_http_receiver_la_SOURCES = simple_http_svr_conn.c\
+				                    http_response_writer.c\
+                                    http_svr_thread.c\
+                                    http_server.c
+
+INCLUDES = -I$(top_builddir)/include \
+           -I$(top_builddir)/modules/util \
+           -I$(top_builddir)/modules/xml/parser\
+	       -I$(top_builddir)/modules/wsdl\
+	       -I$(top_builddir)/modules/core/transport\
+	       -I$(top_builddir)/modules/core/transport/http \
+           -I$(top_builddir)/modules/core/description \
+           -I$(top_builddir)/modules/core/deployment \
+           -I$(top_builddir)/modules/platforms

Added: webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_response_writer.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_response_writer.c?rev=369361&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_response_writer.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_response_writer.c Sun Jan 15 21:58:47 2006
@@ -0,0 +1,317 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+#include <axis2_http_response_writer.h>
+#include <axis2_array_list.h>
+#include <axis2_http_transport.h>
+#include <axis2_string.h>
+
+/** 
+ * @brief HTTP Response Writer struct impl
+ *	Axis2 HTTP Response Writer impl  
+ */
+typedef struct axis2_http_response_writer_impl 
+                    axis2_http_response_writer_impl_t;  
+  
+struct axis2_http_response_writer_impl
+{
+	axis2_http_response_writer_t response_writer;
+    axis2_stream_t *stream;
+    axis2_char_t *encoding;
+};
+
+#define AXIS2_INTF_TO_IMPL(response_writer) \
+                 ((axis2_http_response_writer_impl_t *)(response_writer))
+
+/***************************** Function headers *******************************/
+axis2_char_t* AXIS2_CALL 
+axis2_http_response_writer_get_encoding
+                (axis2_http_response_writer_t *response_writer, 
+                axis2_env_t **env);
+
+axis2_status_t AXIS2_CALL 
+axis2_http_response_writer_close(axis2_http_response_writer_t *response_writer, 
+                axis2_env_t **env);
+
+axis2_status_t AXIS2_CALL 
+axis2_http_response_writer_flush(axis2_http_response_writer_t *response_writer, 
+                axis2_env_t **env);
+
+axis2_status_t AXIS2_CALL 
+axis2_http_response_writer_write_char
+                (axis2_http_response_writer_t *response_writer, 
+                axis2_env_t **env, char c);
+
+axis2_status_t AXIS2_CALL 
+axis2_http_response_writer_write_buf
+                (axis2_http_response_writer_t *response_writer, 
+                axis2_env_t **env, char *buf, int offset, 
+                axis2_ssize_t len);
+
+axis2_status_t AXIS2_CALL 
+axis2_http_response_writer_print_str
+                (axis2_http_response_writer_t *response_writer, 
+                axis2_env_t **env, char *str);
+
+axis2_status_t AXIS2_CALL 
+axis2_http_response_writer_print_int
+                (axis2_http_response_writer_t *response_writer, 
+                axis2_env_t **env, int i);
+
+axis2_status_t AXIS2_CALL 
+axis2_http_response_writer_println_str
+                (axis2_http_response_writer_t *response_writer, 
+                axis2_env_t **env, char *str);
+
+axis2_status_t AXIS2_CALL 
+axis2_http_response_writer_println
+                (axis2_http_response_writer_t *response_writer, 
+                axis2_env_t **env);
+
+axis2_status_t AXIS2_CALL 
+axis2_http_response_writer_free(axis2_http_response_writer_t *response_writer, 
+                axis2_env_t **env);
+
+								
+/***************************** End of function headers ************************/
+axis2_http_response_writer_t* AXIS2_CALL
+axis2_http_response_writer_create (axis2_env_t **env, axis2_stream_t *stream)
+{
+    AXIS2_FUNC_PARAM_CHECK(stream, env, NULL);
+    return axis2_http_response_writer_create_with_encoding(env, stream, 
+                AXIS2_HTTP_DEFAULT_CONTENT_CHARSET);
+    
+}
+
+axis2_http_response_writer_t* AXIS2_CALL
+axis2_http_response_writer_create_with_encoding(axis2_env_t **env,
+                    axis2_stream_t *stream, const axis2_char_t *encoding)
+{
+    AXIS2_FUNC_PARAM_CHECK(stream, env, NULL);
+    AXIS2_PARAM_CHECK((*env)->error, encoding, NULL);
+    
+    axis2_http_response_writer_impl_t *response_writer_impl = 
+                        (axis2_http_response_writer_impl_t *)AXIS2_MALLOC 
+                        ((*env)->allocator, sizeof(
+                        axis2_http_response_writer_impl_t));
+	
+    if(NULL == response_writer_impl)
+	{
+		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    response_writer_impl->stream = stream;
+    response_writer_impl->encoding = (axis2_char_t *)AXIS2_STRDUP(encoding, env);
+    
+    response_writer_impl->response_writer.ops = AXIS2_MALLOC((*env)->allocator,
+        sizeof(axis2_http_response_writer_ops_t));
+    if(NULL == response_writer_impl->response_writer.ops)
+	{
+		axis2_http_response_writer_free((axis2_http_response_writer_t*)
+                                        response_writer_impl, env);
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    
+    response_writer_impl->response_writer.ops->get_encoding = 
+                        axis2_http_response_writer_get_encoding;
+    response_writer_impl->response_writer.ops->close =
+                        axis2_http_response_writer_close;
+    response_writer_impl->response_writer.ops->flush =
+                        axis2_http_response_writer_flush;
+    response_writer_impl->response_writer.ops->write_char = 
+                        axis2_http_response_writer_write_char;
+    response_writer_impl->response_writer.ops->write_buf =
+                        axis2_http_response_writer_write_buf;
+    response_writer_impl->response_writer.ops->print_str =
+                        axis2_http_response_writer_print_str;
+    response_writer_impl->response_writer.ops->print_int =
+                        axis2_http_response_writer_print_int;
+    response_writer_impl->response_writer.ops->println_str =
+                        axis2_http_response_writer_println_str;
+    response_writer_impl->response_writer.ops->println =
+                        axis2_http_response_writer_println;
+    response_writer_impl->response_writer.ops->free =
+                        axis2_http_response_writer_free;
+                        
+	return &(response_writer_impl->response_writer);
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_response_writer_free(axis2_http_response_writer_t *response_writer, 
+                axis2_env_t **env)
+{
+	AXIS2_FUNC_PARAM_CHECK(response_writer, env, AXIS2_FAILURE);
+    AXIS2_FREE((*env)->allocator, 
+                AXIS2_INTF_TO_IMPL(response_writer)->encoding);
+    
+    if(NULL != response_writer->ops)
+        AXIS2_FREE((*env)->allocator, response_writer->ops);
+    
+	AXIS2_FREE((*env)->allocator, AXIS2_INTF_TO_IMPL(response_writer));
+    
+	return AXIS2_SUCCESS;
+}
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_response_writer_get_encoding
+                (axis2_http_response_writer_t *response_writer, 
+                axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(response_writer, env, NULL);
+    return AXIS2_INTF_TO_IMPL(response_writer)->encoding;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_response_writer_close(axis2_http_response_writer_t *response_writer, 
+                axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(response_writer, env, AXIS2_FAILURE);
+    return AXIS2_SUCCESS;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_response_writer_flush(axis2_http_response_writer_t *response_writer, 
+                axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(response_writer, env, AXIS2_FAILURE);
+    /*
+        TODO if bufferring is added flush the buffer
+    */
+    return AXIS2_FALSE;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_response_writer_write_char
+                (axis2_http_response_writer_t *response_writer, 
+                axis2_env_t **env, char c)
+{
+	axis2_http_response_writer_impl_t *writer_impl = NULL;
+	int write = -1;
+    AXIS2_FUNC_PARAM_CHECK(response_writer, env, AXIS2_FAILURE);
+	
+	writer_impl = AXIS2_INTF_TO_IMPL(response_writer);
+	if(NULL == writer_impl->stream)
+	{
+		return AXIS2_FAILURE;
+	}
+    write = AXIS2_STREAM_WRITE(writer_impl->stream, env, &c, 1);
+	if(write < 0)
+	{
+		return AXIS2_FAILURE;
+	}
+    return AXIS2_SUCCESS;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_response_writer_write_buf
+                (axis2_http_response_writer_t *response_writer, 
+                axis2_env_t **env, char *buf, int offset, 
+                axis2_ssize_t len)
+{
+	axis2_http_response_writer_impl_t *writer_impl = NULL;
+	int write = -1;
+    AXIS2_FUNC_PARAM_CHECK(response_writer, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, buf, AXIS2_FAILURE);
+	
+    writer_impl = AXIS2_INTF_TO_IMPL(response_writer);
+	if(NULL == writer_impl->stream)
+	{
+		return AXIS2_FAILURE;
+	}
+    write = AXIS2_STREAM_WRITE(writer_impl->stream, env, buf, len);
+	if(write < 0)
+	{
+		return AXIS2_FAILURE;
+	}
+	/*
+        TODO handle offset
+    */
+    return AXIS2_SUCCESS;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_response_writer_print_str
+                (axis2_http_response_writer_t *response_writer, 
+                axis2_env_t **env, char *str)
+{
+	axis2_http_response_writer_impl_t *writer_impl = NULL;
+	int write = -1;
+	int len = -1;
+	
+    AXIS2_FUNC_PARAM_CHECK(response_writer, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, str, AXIS2_FAILURE);
+    writer_impl = AXIS2_INTF_TO_IMPL(response_writer);
+	
+	len = AXIS2_STRLEN(str);
+	if(NULL == writer_impl->stream)
+	{
+		return AXIS2_FAILURE;
+	}
+    write = AXIS2_STREAM_WRITE(writer_impl->stream, env, str, len);
+	if(write < 0)
+	{
+		return AXIS2_FAILURE;
+	}
+    return AXIS2_SUCCESS;   
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_response_writer_print_int
+                (axis2_http_response_writer_t *response_writer, 
+                axis2_env_t **env, int i)
+{
+    AXIS2_FUNC_PARAM_CHECK(response_writer, env, AXIS2_FAILURE);
+    axis2_char_t int_str[10];
+    sprintf(int_str, "%10d", i);
+    return axis2_http_response_writer_print_str(response_writer, env, int_str);
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_response_writer_println_str
+                (axis2_http_response_writer_t *response_writer, 
+                axis2_env_t **env, char *str)
+{
+    AXIS2_FUNC_PARAM_CHECK(response_writer, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, str, AXIS2_FAILURE);
+    
+    if (AXIS2_SUCCESS == axis2_http_response_writer_print_str(response_writer, 
+                env, str))
+    {
+        return axis2_http_response_writer_print_str(response_writer, env, 
+                AXIS2_HTTP_CRLF);
+    }
+    return AXIS2_FAILURE;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_response_writer_println
+                (axis2_http_response_writer_t *response_writer, 
+                axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(response_writer, env, AXIS2_FAILURE);
+    return axis2_http_response_writer_print_str(response_writer, env, 
+                AXIS2_HTTP_CRLF);
+}

Added: 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=369361&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_server.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_server.c Sun Jan 15 21:58:47 2006
@@ -0,0 +1,257 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+#include <axis2_http_server.h>
+#include <axis2_http_transport.h>
+#include <axis2_http_svr_thread.h>
+#include <axis2_transport_in_desc.h>
+#include <axis2_param_container.h>
+#include <axis2_url.h>
+#include <axis2_conf_init.h>
+
+/** 
+ * @brief HTTP Client struct impl
+ *	Axis2 HTTP Client impl  
+ */
+typedef struct axis2_http_server_impl axis2_http_server_impl_t;  
+  
+struct axis2_http_server_impl
+{
+	axis2_http_server_t http_server;
+	axis2_http_svr_thread_t *svr_thread;
+	int port;
+	axis2_conf_ctx_t* conf_ctx;
+};
+
+#define AXIS2_INTF_TO_IMPL(http_server) \
+                ((axis2_http_server_impl_t *)(http_server))
+
+/***************************** Function servers *******************************/
+axis2_status_t AXIS2_CALL 
+axis2_http_server_init(axis2_http_server_t *server, axis2_env_t **env,
+						axis2_conf_ctx_t *conf_ctx, 
+						axis2_transport_in_desc_t *in_desc);
+axis2_status_t AXIS2_CALL 
+axis2_http_server_start(axis2_http_server_t *server, axis2_env_t **env);
+
+axis2_status_t AXIS2_CALL 
+axis2_http_server_stop(axis2_http_server_t *server, axis2_env_t **env);
+
+axis2_conf_ctx_t* AXIS2_CALL 
+axis2_http_server_get_conf_ctx (axis2_http_server_t *server, axis2_env_t **env);
+
+axis2_endpoint_ref_t* AXIS2_CALL 
+axis2_http_server_get_reply_to_epr(axis2_http_server_t *server, 
+						axis2_env_t **env, axis2_char_t *svc_name);
+
+axis2_bool_t AXIS2_CALL 
+axis2_http_server_is_running (axis2_http_server_t *server, axis2_env_t **env);						
+
+axis2_status_t AXIS2_CALL 
+axis2_http_server_free (axis2_http_server_t *server, axis2_env_t **env);
+
+/***************************** End of function servers ************************/
+
+AXIS2_DECLARE(axis2_http_server_t *) 
+axis2_http_server_create (axis2_env_t **env, axis2_char_t *repo, int port)
+{
+    AXIS2_ENV_CHECK(env, NULL);
+            
+    axis2_http_server_impl_t *server_impl = 
+                        (axis2_http_server_impl_t *)AXIS2_MALLOC 
+                        ((*env)->allocator, sizeof(axis2_http_server_impl_t));
+	
+    if(NULL == server_impl)
+	{
+		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    
+	server_impl->svr_thread = NULL;
+	server_impl->conf_ctx = NULL;
+	server_impl->port = port;
+		
+    server_impl->http_server.ops = AXIS2_MALLOC((*env)->allocator,
+						sizeof(axis2_http_server_ops_t));
+    if(NULL == server_impl->http_server.ops)
+	{
+		axis2_http_server_free((axis2_http_server_t*) server_impl, env);
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    server_impl->conf_ctx = build_conf_ctx(env, repo);
+	if(NULL == server_impl->conf_ctx)
+	{
+		axis2_http_server_free((axis2_http_server_t*) server_impl, env);
+        return NULL;		
+	}
+    server_impl->http_server.ops->init = axis2_http_server_init;                        
+    server_impl->http_server.ops->start = axis2_http_server_start;
+    server_impl->http_server.ops->stop = axis2_http_server_stop;
+	server_impl->http_server.ops->get_conf_ctx = axis2_http_server_get_conf_ctx;
+	server_impl->http_server.ops->get_reply_to_epr = 
+						axis2_http_server_get_reply_to_epr;
+	server_impl->http_server.ops->is_running = 
+						axis2_http_server_is_running;
+	server_impl->http_server.ops->free = axis2_http_server_free;
+                        
+	return &(server_impl->http_server);
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_server_free (axis2_http_server_t *server, axis2_env_t **env)
+{
+	axis2_http_server_impl_t *server_impl = NULL;
+	AXIS2_FUNC_PARAM_CHECK(server, env, AXIS2_FAILURE);
+    server_impl = AXIS2_INTF_TO_IMPL(server);
+    if(NULL != server_impl->svr_thread)
+	{
+		AXIS2_HTTP_SVR_THREAD_DESTROY(server_impl->svr_thread, env);
+		AXIS2_HTTP_SVR_THREAD_FREE(server_impl->svr_thread, env);
+		server_impl->svr_thread = NULL;
+	}
+	if(NULL != server_impl->conf_ctx)
+	{
+		AXIS2_CONF_CTX_FREE(server_impl->conf_ctx, env);
+		server_impl->conf_ctx = NULL;
+	}
+	if(NULL != server->ops)
+	{
+        AXIS2_FREE((*env)->allocator, server->ops);
+    }
+	AXIS2_FREE((*env)->allocator, server_impl);
+	return AXIS2_SUCCESS;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_server_init(axis2_http_server_t *server, axis2_env_t **env,
+						axis2_conf_ctx_t *conf_ctx, 
+						axis2_transport_in_desc_t *in_desc)
+{
+    axis2_http_server_impl_t *server_impl = NULL;
+	axis2_char_t *port_str = NULL;
+	
+	AXIS2_FUNC_PARAM_CHECK(server, env, AXIS2_FAILURE);
+    server_impl = AXIS2_INTF_TO_IMPL(server);
+	
+	server_impl->conf_ctx = conf_ctx;
+	port_str = (axis2_char_t*)AXIS2_PARAM_CONTAINER_GET_PARAM(
+						in_desc->param_container, env, "port");
+	if(NULL != port_str)
+	{
+		server_impl->port = atoi(port_str);
+	}
+	return AXIS2_SUCCESS;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_server_start(axis2_http_server_t *server, axis2_env_t **env)
+{
+
+	axis2_http_server_impl_t *server_impl = NULL;
+	axis2_http_worker_t *worker = NULL;
+    AXIS2_FUNC_PARAM_CHECK(server, env, AXIS2_FAILURE);
+		
+	server_impl = AXIS2_INTF_TO_IMPL(server);
+	server_impl->svr_thread = axis2_http_svr_thread_create(env, 
+						server_impl->port);
+	if(NULL == server_impl->svr_thread)
+	{
+		return AXIS2_FAILURE;
+	}
+	worker = axis2_http_worker_create(env, server_impl->conf_ctx);
+	if(NULL == worker)
+	{
+		AXIS2_HTTP_SVR_THREAD_FREE(server_impl->svr_thread, env);
+		return AXIS2_FAILURE;
+	}
+	AXIS2_LOG_WRITE((*env)->log, "[Axis2]Starting HTTP server thread\n", 
+						AXIS2_LOG_INFO);
+	AXIS2_HTTP_SVR_THREAD_SET_WORKER(server_impl->svr_thread, env, worker);
+	AXIS2_HTTP_SVR_THREAD_RUN(server_impl->svr_thread, env);
+    return AXIS2_SUCCESS;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_server_stop(axis2_http_server_t *server, axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(server, env, AXIS2_FAILURE);
+	
+	AXIS2_LOG_WRITE((*env)->log, "[Axis2]Terminating HTTP server thread\n", 
+						AXIS2_LOG_INFO);
+	if(NULL != AXIS2_INTF_TO_IMPL(server)->svr_thread)
+	{
+		AXIS2_HTTP_SVR_THREAD_DESTROY(AXIS2_INTF_TO_IMPL(server)->svr_thread, 
+						env);
+	}
+	AXIS2_LOG_WRITE((*env)->log, "[Axis2]Successfully terminated  HTTP server\
+						thread\n", AXIS2_LOG_INFO);
+	return AXIS2_SUCCESS;
+}
+
+axis2_conf_ctx_t* AXIS2_CALL 
+axis2_http_server_get_conf_ctx (axis2_http_server_t *server, axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(server, env, NULL);
+	return AXIS2_INTF_TO_IMPL(server)->conf_ctx;
+}
+
+axis2_endpoint_ref_t* AXIS2_CALL 
+axis2_http_server_get_reply_to_epr(axis2_http_server_t *server, 
+						axis2_env_t **env, axis2_char_t *svc_name)
+{
+	axis2_endpoint_ref_t *epr = NULL;
+	axis2_char_t *host_address = NULL;
+	axis2_char_t *svc_path = NULL;
+	axis2_url_t *url = NULL;
+    AXIS2_FUNC_PARAM_CHECK(server, env, NULL);
+    AXIS2_PARAM_CHECK((*env)->error, svc_name, NULL);
+	
+	host_address = "127.0.0.1"; /* TODO : get from axis2.xml */
+	svc_path = AXIS2_STRACAT("/axis2/services/", svc_name, env);
+	url = axis2_url_create(env, "http", host_address, 
+						AXIS2_INTF_TO_IMPL(server)->port, svc_path);
+	AXIS2_FREE((*env)->allocator, svc_path);
+	if(NULL == url)
+	{
+		return NULL;
+	}
+	epr = axis2_endpoint_ref_create(env, AXIS2_URL_TO_EXTERNAL_FORM(url, env));
+	AXIS2_URL_FREE(url, env);
+	return epr;
+}
+
+axis2_bool_t AXIS2_CALL 
+axis2_http_server_is_running (axis2_http_server_t *server, axis2_env_t **env)
+{
+	axis2_http_server_impl_t *server_impl = NULL;
+    AXIS2_FUNC_PARAM_CHECK(server, env, AXIS2_FAILURE);
+    
+	server_impl = AXIS2_INTF_TO_IMPL(server);
+	if(NULL == server_impl->svr_thread)
+	{
+		return AXIS2_FALSE;
+	}
+	else
+	{
+		return AXIS2_HTTP_SVR_THREAD_IS_RUNNING(server_impl->svr_thread, env);
+	}
+	return AXIS2_FALSE;
+}

Added: 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=369361&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_svr_thread.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_svr_thread.c Sun Jan 15 21:58:47 2006
@@ -0,0 +1,221 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+#include <axis2_http_svr_thread.h>
+#include <axis2_http_transport.h>
+#include <axis2_string.h>
+#include <axis2_network_handler.h>
+#include <axis2_http_simple_request.h>
+#include <axis2_simple_http_svr_conn.h>
+#include <axis2_url.h>
+
+
+/** 
+ * @brief HTTP Server Thread struct impl
+ *	Axis2 HTTP Server Thread impl  
+ */
+typedef struct axis2_http_svr_thread_impl axis2_http_svr_thread_impl_t;  
+  
+struct axis2_http_svr_thread_impl
+{
+	axis2_http_svr_thread_t svr_thread;
+	int listen_socket;
+	axis2_bool_t stopped;
+	axis2_http_worker_t *worker;
+	int port;
+};
+
+#define AXIS2_INTF_TO_IMPL(http_svr_thread) \
+                ((axis2_http_svr_thread_impl_t *)(http_svr_thread))
+
+/***************************** Function svr_threads *******************************/
+axis2_status_t AXIS2_CALL 
+axis2_http_svr_thread_run(axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env);
+axis2_status_t AXIS2_CALL 
+axis2_http_svr_thread_destroy(axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env);
+int AXIS2_CALL 
+axis2_http_svr_thread_get_local_port
+						(axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env);
+axis2_bool_t AXIS2_CALL 
+axis2_http_svr_thread_is_running(axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env);
+axis2_status_t AXIS2_CALL 
+axis2_http_svr_thread_set_worker(axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env, axis2_http_worker_t *worker);
+axis2_status_t AXIS2_CALL 
+axis2_http_svr_thread_free (axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env);					
+
+/***************************** End of function svr_threads ************************/
+
+axis2_http_svr_thread_t* AXIS2_CALL
+axis2_http_svr_thread_create (axis2_env_t **env, int port)
+{
+    AXIS2_ENV_CHECK(env, NULL);
+            
+    axis2_http_svr_thread_impl_t *svr_thread_impl = 
+                        (axis2_http_svr_thread_impl_t *)AXIS2_MALLOC 
+                        ((*env)->allocator, sizeof(
+						axis2_http_svr_thread_impl_t));
+	
+    if(NULL == svr_thread_impl)
+	{
+		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    
+	svr_thread_impl->worker = NULL;
+	svr_thread_impl->listen_socket = -1;
+	svr_thread_impl->stopped = AXIS2_FALSE;
+	svr_thread_impl->port = port;
+	
+    svr_thread_impl->svr_thread.ops = AXIS2_MALLOC((*env)->allocator,
+						sizeof(axis2_http_svr_thread_ops_t));
+    if(NULL == svr_thread_impl->svr_thread.ops)
+	{
+		axis2_http_svr_thread_free((axis2_http_svr_thread_t*) svr_thread_impl, 
+						env);
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    
+    svr_thread_impl->svr_thread.ops->run = axis2_http_svr_thread_run;                        
+    svr_thread_impl->svr_thread.ops->destroy = 
+						axis2_http_svr_thread_destroy;
+    svr_thread_impl->svr_thread.ops->get_local_port = 
+						axis2_http_svr_thread_get_local_port;
+	svr_thread_impl->svr_thread.ops->is_running = 
+						axis2_http_svr_thread_is_running;
+	svr_thread_impl->svr_thread.ops->set_worker = 
+						axis2_http_svr_thread_set_worker;
+    svr_thread_impl->svr_thread.ops->free = axis2_http_svr_thread_free;
+                        
+	return &(svr_thread_impl->svr_thread);
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_svr_thread_free (axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env)
+{
+	axis2_http_svr_thread_impl_t *svr_thread_impl = NULL;
+	AXIS2_FUNC_PARAM_CHECK(svr_thread, env, AXIS2_FAILURE);
+    svr_thread_impl = AXIS2_INTF_TO_IMPL(svr_thread);
+	
+    if(NULL != svr_thread_impl->worker)
+    {
+        AXIS2_URL_FREE(svr_thread_impl->worker, env);
+        svr_thread_impl->worker = NULL;
+    }
+    if(-1 != svr_thread_impl->listen_socket)
+    {
+        axis2_network_handler_close_socket(env, svr_thread_impl->listen_socket);
+        svr_thread_impl->listen_socket = -1;
+    }
+	svr_thread_impl->stopped = AXIS2_TRUE;
+    if(NULL != svr_thread->ops)
+        AXIS2_FREE((*env)->allocator, svr_thread->ops);
+    
+	AXIS2_FREE((*env)->allocator, AXIS2_INTF_TO_IMPL(svr_thread));
+	return AXIS2_SUCCESS;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_svr_thread_run(axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env)
+{
+    axis2_http_svr_thread_impl_t *svr_thread_impl = NULL;
+	
+	AXIS2_FUNC_PARAM_CHECK(svr_thread, env, AXIS2_FAILURE);
+    svr_thread_impl = AXIS2_INTF_TO_IMPL(svr_thread);
+	
+	while(AXIS2_FALSE == svr_thread_impl->stopped)
+	{
+		int socket = -1;
+		axis2_simple_http_svr_conn_t *svr_conn = NULL;
+		axis2_http_simple_request_t *request = NULL;
+		socket = axis2_network_handler_svr_socket_accept(env, 
+						svr_thread_impl->listen_socket);
+		if(NULL == svr_thread_impl->worker)
+		{
+			continue;
+		}
+		svr_conn = axis2_simple_http_svr_conn_create(env, socket);
+		request = AXIS2_SIMPLE_HTTP_SVR_CONN_READ_REQUEST(svr_conn, env);
+		axis2_http_worker_t *tmp = NULL;
+		AXIS2_HTTP_WORKER_PROCESS_REQUEST(tmp, env, svr_conn, request);
+		/* TODO log */
+	}
+	
+    return AXIS2_SUCCESS;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_svr_thread_destroy(axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env)
+{
+	axis2_http_svr_thread_impl_t *svr_thread_impl = NULL;
+		
+    AXIS2_FUNC_PARAM_CHECK(svr_thread, env, AXIS2_CRTICAL_FAILURE);
+	
+	svr_thread_impl = AXIS2_INTF_TO_IMPL(svr_thread);
+	if(AXIS2_TRUE == svr_thread_impl->stopped)
+	{
+		return AXIS2_SUCCESS;
+	}
+	svr_thread_impl->stopped = AXIS2_TRUE;
+	/* TODO log*/
+	if(svr_thread_impl->listen_socket)
+	{
+		axis2_network_handler_close_socket(env, svr_thread_impl->listen_socket);
+		svr_thread_impl->listen_socket = -1;
+	}
+	/* TODO: stop all the chiled threads */
+	return AXIS2_SUCCESS;
+}
+
+
+int AXIS2_CALL 
+axis2_http_svr_thread_get_local_port
+						(axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(svr_thread, env, AXIS2_CRTICAL_FAILURE);
+    return AXIS2_INTF_TO_IMPL(svr_thread)->port;
+}
+
+axis2_bool_t AXIS2_CALL 
+axis2_http_svr_thread_is_running(axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(svr_thread, env, AXIS2_FAILURE);
+	return AXIS2_INTF_TO_IMPL(svr_thread)->port;
+}
+
+axis2_status_t AXIS2_CALL 
+axis2_http_svr_thread_set_worker(axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env, axis2_http_worker_t *worker)
+{
+    AXIS2_FUNC_PARAM_CHECK(svr_thread, env, AXIS2_FAILURE);
+	AXIS2_PARAM_CHECK((*env)->error, worker, AXIS2_FAILURE);
+    AXIS2_INTF_TO_IMPL(svr_thread)->worker = worker;
+	return AXIS2_SUCCESS;
+}

Added: webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c?rev=369361&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c Sun Jan 15 21:58:47 2006
@@ -0,0 +1,395 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+#include <axis2_simple_http_svr_conn.h>
+#include <unistd.h>
+#include <axis2_http_transport.h>
+#include <axis2_string.h>
+
+/** 
+ * @brief Simple HTTP Server Connection struct impl
+ *    Axis2 Simple HTTP Server Connection impl  
+ */
+typedef struct axis2_simple_http_svr_conn_impl 
+                                            axis2_simple_http_svr_conn_impl_t;
+  
+struct axis2_simple_http_svr_conn_impl
+{
+    axis2_simple_http_svr_conn_t svr_conn;
+    int socket;
+    axis2_stream_t *stream;
+    axis2_bool_t keep_alive;
+};
+
+#define AXIS2_INTF_TO_IMPL(svr_conn)\
+                ((axis2_simple_http_svr_conn_impl_t *)(svr_conn))
+
+/***************************** Function headers *******************************/
+
+axis2_status_t AXIS2_CALL 
+axis2_simple_http_svr_conn_close(axis2_simple_http_svr_conn_t *svr_conn, 
+                                    axis2_env_t **env);
+
+axis2_bool_t AXIS2_CALL
+axis2_simple_http_svr_conn_is_open(axis2_simple_http_svr_conn_t *svr_conn, 
+                                    axis2_env_t **env);
+
+axis2_status_t AXIS2_CALL 
+axis2_simple_http_svr_conn_set_keep_alive 
+                                    (axis2_simple_http_svr_conn_t *svr_conn, 
+                                    axis2_env_t **env, axis2_bool_t keep_alive);
+
+axis2_bool_t AXIS2_CALL 
+axis2_simple_http_svr_conn_is_keep_alive(axis2_simple_http_svr_conn_t *svr_conn, 
+                                        axis2_env_t **env);
+                                        
+axis2_stream_t* AXIS2_CALL 
+axis2_simple_http_svr_conn_get_stream(axis2_simple_http_svr_conn_t *svr_conn, 
+                                        axis2_env_t **env);
+                                        
+axis2_http_response_writer_t* AXIS2_CALL 
+axis2_simple_http_svr_conn_get_writer(axis2_simple_http_svr_conn_t *svr_conn, 
+                                        axis2_env_t **env);
+                                        
+axis2_http_simple_request_t* AXIS2_CALL 
+axis2_simple_http_svr_conn_read_request(axis2_simple_http_svr_conn_t *svr_conn, 
+                                        axis2_env_t **env);
+                                        
+axis2_status_t AXIS2_CALL 
+axis2_simple_http_svr_conn_write_response
+                                (axis2_simple_http_svr_conn_t *svr_conn, 
+                                axis2_env_t **env, 
+                                axis2_http_simple_response_t *response);
+                                
+axis2_status_t AXIS2_CALL 
+axis2_simple_http_svr_conn_free(axis2_simple_http_svr_conn_t *svr_conn, 
+                                axis2_env_t **env);
+                                
+/***************************** End of function headers ************************/
+
+axis2_simple_http_svr_conn_t* AXIS2_CALL
+axis2_simple_http_svr_conn_create (axis2_env_t **env, int sockfd)
+{
+    AXIS2_ENV_CHECK(env, NULL);
+    axis2_simple_http_svr_conn_impl_t *svr_conn_impl = 
+                                (axis2_simple_http_svr_conn_impl_t *)
+                                AXIS2_MALLOC ((*env)->allocator, 
+                                sizeof(axis2_simple_http_svr_conn_impl_t));
+    
+    if(NULL == svr_conn_impl)
+    {
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+    }
+    svr_conn_impl->socket = sockfd;
+    svr_conn_impl->stream = NULL;
+    svr_conn_impl->keep_alive = AXIS2_FALSE;
+    
+	if(-1 != svr_conn_impl->socket)
+	{
+		svr_conn_impl->stream = axis2_stream_create_socket(env, 
+						svr_conn_impl->socket);
+		if(NULL == svr_conn_impl->stream)
+		{
+			axis2_simple_http_svr_conn_free((axis2_simple_http_svr_conn_t *)
+                                        svr_conn_impl, env);
+			return NULL;
+		}
+	}
+    svr_conn_impl->svr_conn.ops = AXIS2_MALLOC((*env)->allocator,
+        sizeof(axis2_simple_http_svr_conn_ops_t));
+    if(NULL == svr_conn_impl->svr_conn.ops)
+    {
+        axis2_simple_http_svr_conn_free((axis2_simple_http_svr_conn_t *)
+                                        svr_conn_impl, env);
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+    }
+    svr_conn_impl->svr_conn.ops->close = axis2_simple_http_svr_conn_close;
+    svr_conn_impl->svr_conn.ops->is_open = axis2_simple_http_svr_conn_is_open;
+    svr_conn_impl->svr_conn.ops->set_keep_alive =
+                                    axis2_simple_http_svr_conn_set_keep_alive;
+    svr_conn_impl->svr_conn.ops->is_keep_alive = 
+                                    axis2_simple_http_svr_conn_is_keep_alive;
+    svr_conn_impl->svr_conn.ops->get_stream = 
+                                    axis2_simple_http_svr_conn_get_stream;
+    svr_conn_impl->svr_conn.ops->get_writer = 
+                                    axis2_simple_http_svr_conn_get_writer;
+    svr_conn_impl->svr_conn.ops->read_request = 
+                                    axis2_simple_http_svr_conn_read_request;
+    svr_conn_impl->svr_conn.ops->write_response =
+                                    axis2_simple_http_svr_conn_write_response;
+    svr_conn_impl->svr_conn.ops->free = axis2_simple_http_svr_conn_free;
+    return &(svr_conn_impl->svr_conn);
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_simple_http_svr_conn_free(axis2_simple_http_svr_conn_t *svr_conn, 
+                                axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(svr_conn, env, AXIS2_FAILURE);
+    axis2_simple_http_svr_conn_impl_t *svr_conn_impl = 
+                                    AXIS2_INTF_TO_IMPL(svr_conn);
+    if(NULL != svr_conn_impl->stream)
+    {
+        /* TODO free the stream*/
+        AXIS2_FREE((*env)->allocator, svr_conn_impl->stream);
+        svr_conn_impl->stream = NULL;
+    }
+    if(-1 != svr_conn_impl->socket)
+    {
+        close(svr_conn_impl->socket);
+        svr_conn_impl->socket = -1;
+    }
+    if(NULL != svr_conn->ops)
+    {
+        AXIS2_FREE((*env)->allocator, svr_conn->ops);
+        svr_conn->ops = NULL;
+    }
+    
+    AXIS2_FREE((*env)->allocator, svr_conn_impl);
+    svr_conn_impl = NULL;
+    
+    return AXIS2_SUCCESS;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_simple_http_svr_conn_close(axis2_simple_http_svr_conn_t *svr_conn, 
+                                    axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(svr_conn, env, AXIS2_FAILURE);
+    axis2_simple_http_svr_conn_impl_t *svr_conn_impl = 
+                                    AXIS2_INTF_TO_IMPL(svr_conn);
+    if(-1 != svr_conn_impl->socket)
+    {
+        close(svr_conn_impl->socket);
+        svr_conn_impl->socket = -1;
+    }
+    /*
+        TODO close the stream
+    */
+    return AXIS2_SUCCESS;
+}
+
+
+axis2_bool_t AXIS2_CALL
+axis2_simple_http_svr_conn_is_open(axis2_simple_http_svr_conn_t *svr_conn, 
+                                    axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(svr_conn, env, AXIS2_FAILURE);
+    axis2_simple_http_svr_conn_impl_t *svr_conn_impl = 
+                                    AXIS2_INTF_TO_IMPL(svr_conn);
+    if(-1 != svr_conn_impl->socket)
+    {
+        return AXIS2_TRUE;
+    }
+    else
+    {
+        return AXIS2_FALSE;
+    }
+    return AXIS2_FALSE;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_simple_http_svr_conn_set_keep_alive 
+                                    (axis2_simple_http_svr_conn_t *svr_conn, 
+                                    axis2_env_t **env, axis2_bool_t keep_alive)
+{
+    AXIS2_FUNC_PARAM_CHECK(svr_conn, env, AXIS2_FAILURE);
+    AXIS2_INTF_TO_IMPL(svr_conn)->keep_alive = keep_alive;
+    return AXIS2_SUCCESS;
+}
+
+
+axis2_bool_t AXIS2_CALL 
+axis2_simple_http_svr_conn_is_keep_alive(axis2_simple_http_svr_conn_t *svr_conn, 
+                                        axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(svr_conn, env, AXIS2_FAILURE);
+    
+    return AXIS2_INTF_TO_IMPL(svr_conn)->keep_alive;
+}
+
+
+axis2_stream_t* AXIS2_CALL 
+axis2_simple_http_svr_conn_get_stream(axis2_simple_http_svr_conn_t *svr_conn, 
+                                        axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(svr_conn, env, NULL);
+    return AXIS2_INTF_TO_IMPL(svr_conn)->stream;
+}
+
+
+axis2_http_response_writer_t* AXIS2_CALL 
+axis2_simple_http_svr_conn_get_writer(axis2_simple_http_svr_conn_t *svr_conn, 
+                                        axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(svr_conn, env, NULL);
+    return axis2_http_response_writer_create(env, 
+                                        AXIS2_INTF_TO_IMPL(svr_conn)->stream);
+    
+}
+
+
+axis2_http_simple_request_t* AXIS2_CALL 
+axis2_simple_http_svr_conn_read_request(axis2_simple_http_svr_conn_t *svr_conn, 
+                                        axis2_env_t **env)
+{
+	axis2_char_t str_line[1024];
+	axis2_char_t tmp_buf[3];
+	axis2_simple_http_svr_conn_impl_t *svr_conn_impl = NULL;
+	int read = -1;
+	axis2_bool_t end_of_line = AXIS2_FALSE;
+	axis2_bool_t end_of_headers = AXIS2_FALSE;
+	axis2_http_request_line_t *request_line = NULL;
+	axis2_http_simple_request_t *request = NULL;
+	
+    AXIS2_FUNC_PARAM_CHECK(svr_conn, env, NULL);
+	
+    svr_conn_impl = AXIS2_INTF_TO_IMPL(svr_conn);
+	memset(str_line, 0, 1024);
+	while((read = AXIS2_STREAM_READ(svr_conn_impl->stream, env, tmp_buf, 
+						1)) > 0)
+	{
+		tmp_buf[read] = '\0';
+		strcat(str_line, tmp_buf);
+		if(0 != strstr(str_line, AXIS2_HTTP_CRLF))
+		{
+			end_of_line = AXIS2_TRUE;
+		}
+		if(AXIS2_TRUE == end_of_line)
+		{
+			break;
+		}
+	}
+	request_line = axis2_http_request_line_parse_line(env, str_line);
+	if(NULL == request_line)
+	{
+		AXIS2_ERROR_SET((*env)->error, 
+						AXIS2_ERROR_INVALID_HTTP_INVALID_HEADER_START_LINE, 
+						AXIS2_FAILURE);
+		return NULL;
+	}
+	request = axis2_http_simple_request_create(env, request_line, NULL , 0, 
+						svr_conn_impl->stream);
+	/* now read the headers */
+	memset(str_line, 0, 1024);
+	end_of_line = AXIS2_FALSE;
+	while(AXIS2_FALSE == end_of_headers)
+	{
+		while((read = AXIS2_STREAM_READ(svr_conn_impl->stream, env, tmp_buf, 
+							1)) > 0)
+		{
+			tmp_buf[read] = '\0';
+			strcat(str_line, tmp_buf);
+			if(0 != strstr(str_line, AXIS2_HTTP_CRLF))
+			{
+				end_of_line = AXIS2_TRUE;
+				break;
+			}
+		}
+		if(AXIS2_TRUE == end_of_line)
+		{
+			if(0 == AXIS2_STRCMP(str_line, AXIS2_HTTP_CRLF))
+			{
+				end_of_headers = AXIS2_TRUE;
+			}
+			else
+			{
+				axis2_http_header_t *tmp_header = 
+						axis2_http_header_create_by_str(env, str_line);
+				memset(str_line, 0, 1024);
+				if(NULL != tmp_header)
+				{
+					AXIS2_HTTP_SIMPLE_REQUEST_ADD_HEADER(request, env, 
+						tmp_header);
+				}
+			}
+		}
+		end_of_line = AXIS2_FALSE;
+	}
+    return request;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_simple_http_svr_conn_write_response
+						(axis2_simple_http_svr_conn_t *svr_conn, 
+						axis2_env_t **env, 
+						axis2_http_simple_response_t *response)
+{
+	axis2_http_response_writer_t *response_writer = NULL;
+	axis2_simple_http_svr_conn_impl_t *svr_conn_impl = NULL;
+	axis2_array_list_t *headers = NULL;
+	axis2_stream_t *response_stream = NULL;
+	axis2_char_t *response_body = NULL;
+	int body_size = 0;
+	int i = 0;
+	
+    AXIS2_FUNC_PARAM_CHECK(svr_conn, env, AXIS2_FAILURE);
+	AXIS2_PARAM_CHECK((*env)->error, response, AXIS2_FAILURE);
+	
+	svr_conn_impl = AXIS2_INTF_TO_IMPL(svr_conn);
+	response_writer = axis2_http_response_writer_create(env, 
+						svr_conn_impl->stream);
+	if(NULL == response_writer)
+	{
+		return AXIS2_FAILURE;
+	}
+	
+	AXIS2_HTTP_RESPONSE_WRITER_PRINTLN_STR(response_writer, env, 
+						AXIS2_HTTP_SIMPLE_RESPONSE_GET_STAUTUS_LINE(response, 
+						env));
+	headers = AXIS2_HTTP_SIMPLE_RESPONSE_GET_HEADERS(response, env);
+	
+	
+	
+	for(i = 0; i < AXIS2_ARRAY_LIST_SIZE(headers, env); i++)
+	{
+		axis2_http_header_t *header = NULL;
+		header = (axis2_http_header_t *)AXIS2_ARRAY_LIST_GET(headers, env, i);
+		if(NULL != header)
+		{
+			AXIS2_HTTP_RESPONSE_WRITER_PRINTLN_STR(response_writer, env, 
+						AXIS2_HTTP_HEADER_TO_EXTERNAL_FORM(
+						(axis2_http_header_t*)header, env));
+		}
+	}
+	AXIS2_HTTP_RESPONSE_WRITER_PRINTLN(response_writer, env);
+	
+	response_stream = AXIS2_HTTP_SIMPLE_RESPONSE_GET_BODY(response, env);
+	body_size = AXIS2_HTTP_SIMPLE_RESPONSE_GET_BODY_BYTES(response, env, 
+						&response_body);
+	if(body_size > 0)
+	{
+		int write_size = 0;
+		write_size = AXIS2_STREAM_WRITE(response_stream, env, response_body, 
+						body_size);
+		if(write_size < 0)
+		{
+			AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_WRITING_RESPONSE, 
+						AXIS2_FAILURE);
+			return AXIS2_FAILURE;
+		}
+	}
+    /*
+        TODO chunking
+    */
+    return AXIS2_SUCCESS;
+}

Added: webservices/axis2/trunk/c/modules/core/transport/http/sender/Makefile.am
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/sender/Makefile.am?rev=369361&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/Makefile.am (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/Makefile.am Sun Jan 15 21:58:47 2006
@@ -0,0 +1,14 @@
+lib_LTLIBRARIES = libaxis2_http_sender.la
+AM_CPPFLAGS = $(CPPFLAGS)
+libaxis2_http_sender_la_SOURCES = http_transport_sender.c\
+                                  soap_over_http_sender.c\
+                                  http_client.c
+
+INCLUDES = -I$(top_builddir)/include \
+           -I$(top_builddir)/modules/util \
+           -I$(top_builddir)/modules/xml/parser\
+	       -I$(top_builddir)/modules/wsdl\
+	       -I$(top_builddir)/modules/core/transport\
+	       -I$(top_builddir)/modules/core/transport/http \
+           -I$(top_builddir)/modules/core/description \
+            -I$(top_builddir)/modules/platforms



Mime
View raw message