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 [1/3] - in /webservices/axis2/trunk/c/modules/core/transport/http: ./ receiver/ sender/
Date Mon, 16 Jan 2006 05:59:11 GMT
Author: samisa
Date: Sun Jan 15 21:58:47 2006
New Revision: 369361

URL: http://svn.apache.org/viewcvs?rev=369361&view=rev
Log:
Removed 'axis2' prefixes. Moved to sender, reciever 

Added:
    webservices/axis2/trunk/c/modules/core/transport/http/http_header.c
    webservices/axis2/trunk/c/modules/core/transport/http/http_out_transport_info.c
    webservices/axis2/trunk/c/modules/core/transport/http/http_request_line.c
    webservices/axis2/trunk/c/modules/core/transport/http/http_simple_request.c
    webservices/axis2/trunk/c/modules/core/transport/http/http_simple_response.c
    webservices/axis2/trunk/c/modules/core/transport/http/http_status_line.c
    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/
    webservices/axis2/trunk/c/modules/core/transport/http/receiver/Makefile.am
    webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_response_writer.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/receiver/simple_http_svr_conn.c
    webservices/axis2/trunk/c/modules/core/transport/http/sender/
    webservices/axis2/trunk/c/modules/core/transport/http/sender/Makefile.am
    webservices/axis2/trunk/c/modules/core/transport/http/sender/http_client.c
    webservices/axis2/trunk/c/modules/core/transport/http/sender/http_transport_sender.c
    webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c
Removed:
    webservices/axis2/trunk/c/modules/core/transport/http/axis2_http_client.c
    webservices/axis2/trunk/c/modules/core/transport/http/axis2_http_header.c
    webservices/axis2/trunk/c/modules/core/transport/http/axis2_http_out_transport_info.c
    webservices/axis2/trunk/c/modules/core/transport/http/axis2_http_request_line.c
    webservices/axis2/trunk/c/modules/core/transport/http/axis2_http_response_writer.c
    webservices/axis2/trunk/c/modules/core/transport/http/axis2_http_simple_request.c
    webservices/axis2/trunk/c/modules/core/transport/http/axis2_http_simple_response.c
    webservices/axis2/trunk/c/modules/core/transport/http/axis2_http_status_line.c
    webservices/axis2/trunk/c/modules/core/transport/http/axis2_http_transport_sender.c
    webservices/axis2/trunk/c/modules/core/transport/http/axis2_http_transport_utils.c
    webservices/axis2/trunk/c/modules/core/transport/http/axis2_http_worker.c
    webservices/axis2/trunk/c/modules/core/transport/http/axis2_simple_http_svr_conn.c
    webservices/axis2/trunk/c/modules/core/transport/http/axis2_soap_over_http_sender.c

Added: webservices/axis2/trunk/c/modules/core/transport/http/http_header.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/http_header.c?rev=369361&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/http_header.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/http_header.c Sun Jan 15 21:58:47 2006
@@ -0,0 +1,177 @@
+/*
+ * 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_header.h>
+#include <axis2_string.h>
+#include <axis2_http_transport.h>
+
+
+/** 
+ * @brief HTTP Header struct impl
+ *	Axis2 HTTP Header impl  
+ */
+typedef struct axis2_http_header_impl axis2_http_header_impl_t;  
+  
+struct axis2_http_header_impl
+{
+	axis2_http_header_t http_header;
+	axis2_char_t *name;
+    axis2_char_t *value;
+};
+
+#define AXIS2_INTF_TO_IMPL(http_header) \
+                ((axis2_http_header_impl_t *)(http_header))
+
+/***************************** Function headers *******************************/
+axis2_char_t* AXIS2_CALL 
+axis2_http_header_to_external_form (axis2_http_header_t *header, 
+                axis2_env_t **env);
+    
+axis2_char_t* AXIS2_CALL 
+axis2_http_header_get_name (axis2_http_header_t *header, axis2_env_t **env);
+    
+axis2_char_t* AXIS2_CALL 
+axis2_http_header_get_value (axis2_http_header_t *header, axis2_env_t **env);
+    
+axis2_status_t AXIS2_CALL 
+axis2_http_header_free (axis2_http_header_t *header, axis2_env_t **env);								
+
+/***************************** End of function headers ************************/
+
+AXIS2_DECLARE(axis2_http_header_t *) AXIS2_CALL
+axis2_http_header_create (axis2_env_t **env, axis2_char_t *name, 
+                            axis2_char_t *value)
+{
+    AXIS2_ENV_CHECK(env, NULL);
+    AXIS2_FUNC_PARAM_CHECK(name, env, NULL);
+    AXIS2_FUNC_PARAM_CHECK(value, env, NULL);
+        
+    axis2_http_header_impl_t *http_header_impl = 
+                        (axis2_http_header_impl_t *)AXIS2_MALLOC 
+                        ((*env)->allocator, sizeof(
+                        axis2_http_header_impl_t));
+	
+    if(NULL == http_header_impl)
+	{
+		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    http_header_impl->name = (axis2_char_t *)AXIS2_STRDUP(name, env);
+    http_header_impl->value = (axis2_char_t *)AXIS2_STRDUP(value, env);
+     
+    http_header_impl->http_header.ops = AXIS2_MALLOC((*env)->allocator,
+        sizeof(axis2_http_header_ops_t));
+    if(NULL == http_header_impl->http_header.ops)
+	{
+		axis2_http_header_free((axis2_http_header_t*)
+                         http_header_impl, env);
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    
+    http_header_impl->http_header.ops->to_external_form = 
+                        axis2_http_header_to_external_form;
+    http_header_impl->http_header.ops->get_name = axis2_http_header_get_name;
+    http_header_impl->http_header.ops->get_value = axis2_http_header_get_value;
+    http_header_impl->http_header.ops->free = axis2_http_header_free;
+                        
+	return &(http_header_impl->http_header);
+}
+
+AXIS2_DECLARE(axis2_http_header_t *) AXIS2_CALL
+axis2_http_header_create_by_str (axis2_env_t **env, axis2_char_t *str)
+{
+	axis2_char_t *tmp_str = NULL;
+	axis2_char_t *ch = NULL;
+	axis2_char_t *ch2 = NULL;
+	axis2_http_header_t *ret = NULL;
+	AXIS2_ENV_CHECK(env, NULL);
+    AXIS2_FUNC_PARAM_CHECK(str, env, NULL);
+	
+	tmp_str = AXIS2_STRDUP(str, env);
+	if(NULL == tmp_str)
+	{
+		return NULL;
+	}
+	ch = strchr(tmp_str, ':');
+	if(NULL == ch)
+	{
+		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_INVALID_HEADER, 
+						AXIS2_FAILURE);
+		AXIS2_FREE((*env)->allocator, tmp_str);
+		return NULL;
+	}
+	ch2 = ch + sizeof(axis2_char_t);
+	*ch = '\0';
+	ret = axis2_http_header_create(env, tmp_str, ch2);
+	AXIS2_FREE((*env)->allocator, tmp_str);
+	return ret;	
+}
+
+axis2_status_t AXIS2_CALL 
+axis2_http_header_free (axis2_http_header_t *header, axis2_env_t **env)
+{
+	AXIS2_FUNC_PARAM_CHECK(header, env, AXIS2_FAILURE);
+    axis2_http_header_impl_t *http_header_impl =
+                        AXIS2_INTF_TO_IMPL(header);
+    if(NULL != http_header_impl->name)
+    {
+        AXIS2_FREE((*env)->allocator, http_header_impl->name);
+        http_header_impl->name = NULL;
+    }
+    if(NULL != http_header_impl->value)
+    {
+        AXIS2_FREE((*env)->allocator, http_header_impl->value);
+        http_header_impl->value = NULL;
+    }
+    if(NULL != header->ops)
+        AXIS2_FREE((*env)->allocator, header->ops);
+    
+	AXIS2_FREE((*env)->allocator, AXIS2_INTF_TO_IMPL(header));
+	return AXIS2_SUCCESS;
+}
+
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_header_to_external_form (axis2_http_header_t *header, 
+                axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(header, env, NULL);
+    axis2_http_header_impl_t *http_header_impl = AXIS2_INTF_TO_IMPL(header);
+    axis2_ssize_t len = AXIS2_STRLEN(http_header_impl->name) + 
+                AXIS2_STRLEN(http_header_impl->value) + 4;
+    axis2_char_t *external_form = (axis2_char_t*) AXIS2_MALLOC((*env)->allocator,
+                len);
+    sprintf(external_form, "%s:%s%s", http_header_impl->name, 
+                http_header_impl->value, AXIS2_HTTP_CRLF);
+    return external_form;
+}
+
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_header_get_name (axis2_http_header_t *header, axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(header, env, NULL);
+    return AXIS2_INTF_TO_IMPL(header)->name;
+}
+
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_header_get_value (axis2_http_header_t *header, axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(header, env, NULL);
+    return AXIS2_INTF_TO_IMPL(header)->value;
+}

Added: webservices/axis2/trunk/c/modules/core/transport/http/http_out_transport_info.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/http_out_transport_info.c?rev=369361&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/http_out_transport_info.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/http_out_transport_info.c Sun Jan 15 21:58:47 2006
@@ -0,0 +1,172 @@
+/*
+ * 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_out_transport_info.h>
+#include <axis2_string.h>
+#include <axis2_http_transport.h>
+#include <axis2_string.h>
+
+
+/** 
+ * @brief HTTP Header struct impl
+ *	Axis2 HTTP Header impl  
+ */
+typedef struct axis2_http_out_transport_info_impl 
+				axis2_http_out_transport_info_impl_t;  
+  
+struct axis2_http_out_transport_info_impl
+{
+	axis2_http_out_transport_info_t out_transport_info;
+	axis2_http_simple_response_t *response;
+	axis2_char_t *encoding;
+};
+
+#define AXIS2_INTF_TO_IMPL(out_transport_info) \
+                ((axis2_http_out_transport_info_impl_t *)(out_transport_info))
+
+/***************************** Function headers *******************************/
+axis2_status_t AXIS2_CALL 
+axis2_http_out_transport_info_set_content_type 
+				(axis2_http_out_transport_info_t *info, axis2_env_t **env, 
+				axis2_char_t *content_type);
+    
+axis2_status_t AXIS2_CALL 
+axis2_http_out_transport_info_set_char_encoding 
+				(axis2_http_out_transport_info_t *info, axis2_env_t **env,
+				axis2_char_t *encoding);
+    
+axis2_status_t AXIS2_CALL 
+axis2_http_out_transport_info_free 
+				(axis2_http_out_transport_info_t *out_transport_info, 
+				axis2_env_t **env);
+
+/***************************** End of function headers ************************/
+
+axis2_http_out_transport_info_t * AXIS2_CALL 
+axis2_http_out_transport_info_create(axis2_env_t **env,
+					axis2_http_simple_response_t *response)
+{
+    AXIS2_ENV_CHECK(env, NULL);
+    AXIS2_FUNC_PARAM_CHECK(response, env, NULL);
+        
+    axis2_http_out_transport_info_impl_t *info_impl = 
+                        (axis2_http_out_transport_info_impl_t *)AXIS2_MALLOC 
+                        ((*env)->allocator, sizeof(
+                        axis2_http_out_transport_info_impl_t));
+	
+    if(NULL == info_impl)
+	{
+		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    info_impl->response = response;
+  	info_impl->encoding = NULL;  
+     
+    info_impl->out_transport_info.ops = AXIS2_MALLOC((*env)->allocator,
+        				sizeof(axis2_http_out_transport_info_ops_t));
+    if(NULL == info_impl->out_transport_info.ops)
+	{
+		axis2_http_out_transport_info_free((axis2_http_out_transport_info_t*)
+                         info_impl, env);
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+		return NULL;
+	}
+
+    info_impl->out_transport_info.ops->set_content_type = 
+						axis2_http_out_transport_info_set_content_type;
+    info_impl->out_transport_info.ops->set_char_encoding = 
+						axis2_http_out_transport_info_set_char_encoding;
+    info_impl->out_transport_info.ops->free = 
+						axis2_http_out_transport_info_free;
+                        
+	return &(info_impl->out_transport_info);
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_out_transport_info_free (axis2_http_out_transport_info_t *info, 
+						axis2_env_t **env)
+{
+	AXIS2_FUNC_PARAM_CHECK(info, env, AXIS2_FAILURE);
+    axis2_http_out_transport_info_impl_t *info_impl =
+                        AXIS2_INTF_TO_IMPL(info);
+	
+	info_impl->response = NULL; /* response doesn't belong to info */
+    if(NULL != info_impl->encoding)
+    {
+        AXIS2_FREE((*env)->allocator, info_impl->encoding);
+        info_impl->encoding = NULL;
+    }
+    if(NULL != info->ops)
+        AXIS2_FREE((*env)->allocator, info->ops);
+    
+	AXIS2_FREE((*env)->allocator, info_impl);
+	return AXIS2_SUCCESS;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_out_transport_info_set_content_type 
+				(axis2_http_out_transport_info_t *info, axis2_env_t **env, 
+				axis2_char_t *content_type)
+{
+    axis2_char_t *tmp1 = NULL;
+	axis2_char_t *tmp2 = NULL;
+	
+	AXIS2_FUNC_PARAM_CHECK(info, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, content_type, AXIS2_FAILURE);
+	
+	axis2_http_out_transport_info_impl_t *info_impl = AXIS2_INTF_TO_IMPL(info);
+	
+	if(NULL != info_impl->encoding)
+	{
+		
+		tmp1 = AXIS2_STRACAT(content_type, ";charset=", env);
+		tmp2 = AXIS2_STRACAT(tmp1, info_impl->encoding, env);
+		AXIS2_HTTP_SIMPLE_RESPONSE_SET_HEADER(info_impl->response, env, 
+				axis2_http_header_create(env, AXIS2_HTTP_HEADER_CONTENT_TYPE, 
+				tmp2));
+		AXIS2_FREE((*env)->allocator, tmp1);
+		AXIS2_FREE((*env)->allocator, tmp2);		
+	}
+	else
+	{
+		AXIS2_HTTP_SIMPLE_RESPONSE_SET_HEADER(info_impl->response, env, 
+				axis2_http_header_create(env, AXIS2_HTTP_HEADER_CONTENT_TYPE, 
+				content_type));
+	}
+	return AXIS2_SUCCESS;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_out_transport_info_set_char_encoding 
+				(axis2_http_out_transport_info_t *info, axis2_env_t **env,
+				axis2_char_t *encoding)
+{
+    AXIS2_FUNC_PARAM_CHECK(info, env, AXIS2_FAILURE);
+	AXIS2_PARAM_CHECK((*env)->error, encoding, AXIS2_FAILURE);
+	
+    axis2_http_out_transport_info_impl_t *info_impl = AXIS2_INTF_TO_IMPL(info);
+	
+	if(NULL != info_impl->encoding)
+	{
+		AXIS2_FREE((*env)->allocator, info_impl->encoding);
+	}
+	info_impl->encoding = AXIS2_STRDUP(encoding, env);
+	
+	return AXIS2_SUCCESS;
+}

Added: webservices/axis2/trunk/c/modules/core/transport/http/http_request_line.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/http_request_line.c?rev=369361&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/http_request_line.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/http_request_line.c Sun Jan 15 21:58:47 2006
@@ -0,0 +1,258 @@
+/*
+ * 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_request_line.h>
+#include <axis2_string.h>
+#include <string.h>
+#include <axis2_http_transport.h>
+
+/** 
+ * @brief HTTP Request Line struct impl
+ *	Axis2 HTTP Request Line impl  
+ */
+typedef struct axis2_http_request_line_impl axis2_http_request_line_impl_t;  
+  
+struct axis2_http_request_line_impl
+{
+	axis2_http_request_line_t request_line;
+	axis2_char_t *http_version;
+    axis2_char_t *method;
+    axis2_char_t *uri;
+};
+
+#define AXIS2_INTF_TO_IMPL(request_line) \
+                 ((axis2_http_request_line_impl_t *)(request_line))
+
+/***************************** Function headers *******************************/
+
+/*  
+ *  This is just a function
+ *  Not assciated with an ops struct
+ */
+axis2_http_request_line_t* AXIS2_CALL 
+axis2_http_request_line_parse_line(axis2_env_t **env, const axis2_char_t *str);
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_request_line_get_method(axis2_http_request_line_t *request_line, 
+                            axis2_env_t **env);
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_request_line_get_http_version
+                            (axis2_http_request_line_t *request_line, 
+                            axis2_env_t **env);
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_request_line_get_uri(axis2_http_request_line_t *request_line, 
+                            axis2_env_t **env);
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_request_line_to_string(axis2_http_request_line_t *request_line, 
+                            axis2_env_t **env);
+
+axis2_status_t AXIS2_CALL 
+axis2_http_request_line_free(axis2_http_request_line_t *request_line, 
+                            axis2_env_t **env);								
+/***************************** End of function headers ************************/
+
+axis2_http_request_line_t * AXIS2_CALL 
+axis2_http_request_line_create(axis2_env_t **env, axis2_char_t *method, 
+                                axis2_char_t *uri, axis2_char_t *http_version)
+{
+    AXIS2_ENV_CHECK(env, NULL);
+    AXIS2_PARAM_CHECK((*env)->error, method, NULL);
+    AXIS2_PARAM_CHECK((*env)->error, uri, NULL);
+    AXIS2_PARAM_CHECK((*env)->error, http_version, NULL);
+        
+    axis2_http_request_line_impl_t *request_line_impl = 
+                        (axis2_http_request_line_impl_t *)AXIS2_MALLOC 
+                        ((*env)->allocator, sizeof(
+                        axis2_http_request_line_impl_t));
+	
+    if(NULL == request_line_impl)
+	{
+		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    request_line_impl->method = (axis2_char_t *)AXIS2_STRDUP(method, env);
+    request_line_impl->uri = (axis2_char_t *)AXIS2_STRDUP(uri, env);
+    request_line_impl->http_version = (axis2_char_t *)AXIS2_STRDUP(
+                         http_version, env);
+     
+    request_line_impl->request_line.ops = AXIS2_MALLOC((*env)->allocator,
+        sizeof(axis2_http_request_line_ops_t));
+    if(NULL == request_line_impl->request_line.ops)
+	{
+		axis2_http_request_line_free((axis2_http_request_line_t*)
+                         request_line_impl, env);
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    
+    request_line_impl->request_line.ops->get_method =
+                        axis2_http_request_line_get_method;
+    request_line_impl->request_line.ops->get_http_version =
+                        axis2_http_request_line_get_http_version;
+    request_line_impl->request_line.ops->get_uri =
+                        axis2_http_request_line_get_uri;
+    request_line_impl->request_line.ops->to_string =
+                        axis2_http_request_line_to_string;
+    request_line_impl->request_line.ops->free =
+                        axis2_http_request_line_free;
+	return &(request_line_impl->request_line);
+}
+
+axis2_status_t AXIS2_CALL
+axis2_http_request_line_free(axis2_http_request_line_t *request_line, 
+                        axis2_env_t **env)
+{
+	AXIS2_FUNC_PARAM_CHECK(request_line, env, AXIS2_FAILURE);
+    axis2_http_request_line_impl_t *request_line_impl =
+                        AXIS2_INTF_TO_IMPL(request_line);
+    if(NULL != request_line_impl->method)
+    {
+        AXIS2_FREE((*env)->allocator, request_line_impl->method);
+        request_line_impl->method = NULL;
+    }
+    if(NULL != request_line_impl->uri)
+    {
+        AXIS2_FREE((*env)->allocator, request_line_impl->uri);
+        request_line_impl->uri = NULL;
+    }
+    if(NULL != request_line_impl->http_version)
+    {
+        AXIS2_FREE((*env)->allocator, request_line_impl->http_version);
+        request_line_impl->http_version = NULL;
+    }        
+    if(NULL != request_line->ops)
+        AXIS2_FREE((*env)->allocator, request_line->ops);
+    
+	AXIS2_FREE((*env)->allocator, AXIS2_INTF_TO_IMPL(request_line));
+	return AXIS2_SUCCESS;
+}
+
+axis2_http_request_line_t* AXIS2_CALL 
+axis2_http_request_line_parse_line(axis2_env_t **env, const axis2_char_t *str)
+{
+    AXIS2_PARAM_CHECK((*env)->error, str, NULL);
+    axis2_char_t *tmp = strstr(str, AXIS2_HTTP_CRLF);
+    axis2_char_t *req_line = NULL;
+    axis2_char_t *method = NULL;
+    axis2_char_t *uri = NULL;
+    axis2_char_t *http_version = NULL;
+    axis2_http_request_line_t *ret = NULL;
+    
+    int i = 0;
+    
+    if(NULL == tmp)
+    {
+        AXIS2_ERROR_SET((*env)->error, 
+                        AXIS2_ERROR_INVALID_HTTP_INVALID_HEADER_START_LINE, 
+                        AXIS2_FAILURE);
+        return NULL;
+    }
+    i = tmp - str;
+    req_line = AXIS2_MALLOC((*env)->allocator, i * sizeof(axis2_char_t) +1);
+    if(NULL == req_line)
+    {
+       AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;        
+    }
+    memcpy(req_line, str, i * sizeof(axis2_char_t));
+    req_line[i] = '\0';
+    tmp = req_line;
+    
+    method = tmp;
+    tmp = strchr(tmp, ' ');
+    if(NULL == tmp)
+    {
+        AXIS2_FREE((*env)->allocator, req_line);
+        AXIS2_ERROR_SET((*env)->error, 
+                    AXIS2_ERROR_INVALID_HTTP_INVALID_HEADER_START_LINE, 
+                    AXIS2_FAILURE);
+        return NULL;
+    }
+    *tmp++ = '\0';
+    uri = tmp;
+    tmp = strchr(tmp, ' ');
+    if(NULL == tmp)
+    {
+        AXIS2_FREE((*env)->allocator, req_line);
+        AXIS2_ERROR_SET((*env)->error, 
+                    AXIS2_ERROR_INVALID_HTTP_INVALID_HEADER_START_LINE, 
+                    AXIS2_FAILURE);
+        return NULL;
+    }
+    *tmp++ = '\0';
+    http_version = tmp;
+    ret = axis2_http_request_line_create(env, method, uri, http_version);
+    AXIS2_FREE((*env)->allocator, req_line);
+    
+    return ret;    
+}
+
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_request_line_get_method(axis2_http_request_line_t *request_line, 
+                            axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(request_line, env, NULL);
+    return AXIS2_INTF_TO_IMPL(request_line)->method;
+}
+
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_request_line_get_http_version
+                            (axis2_http_request_line_t *request_line, 
+                            axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(request_line, env, NULL);
+    return AXIS2_INTF_TO_IMPL(request_line)->http_version;
+}
+
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_request_line_get_uri(axis2_http_request_line_t *request_line, 
+                            axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(request_line, env, NULL);
+    return AXIS2_INTF_TO_IMPL(request_line)->uri;
+}
+
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_request_line_to_string(axis2_http_request_line_t *request_line, 
+                            axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(request_line, env, NULL);
+    
+    axis2_http_request_line_impl_t *req_line_impl = AXIS2_INTF_TO_IMPL(
+                            request_line);
+    int alloc_len = AXIS2_STRLEN(req_line_impl->method) + 
+                    AXIS2_STRLEN(req_line_impl->uri)+
+                    AXIS2_STRLEN(req_line_impl->http_version) + 5;
+    /* 5 = 2 * spaces + CR + LF + '\0' */
+
+    axis2_char_t *ret = AXIS2_MALLOC((*env)->allocator, 
+                    alloc_len * sizeof(axis2_char_t));
+    if(NULL == ret)
+    {
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); 
+        return NULL;
+    }
+    sprintf(ret, "%s %s %s%s", req_line_impl->method, req_line_impl->uri, 
+                    req_line_impl->http_version, AXIS2_HTTP_CRLF);
+    return ret;
+}

Added: webservices/axis2/trunk/c/modules/core/transport/http/http_simple_request.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/http_simple_request.c?rev=369361&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/http_simple_request.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/http_simple_request.c Sun Jan 15 21:58:47 2006
@@ -0,0 +1,531 @@
+/*
+ * 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_simple_request.h>
+#include <axis2_array_list.h>
+#include <axis2_http_transport.h>
+#include <axis2_string.h>
+#include <string.h>
+
+/** 
+ * @brief HTTP Simple Request struct impl
+ *	Axis2 HTTP Simple Request impl  
+ */
+typedef struct axis2_http_simple_request_impl axis2_http_simple_request_impl_t;  
+  
+struct axis2_http_simple_request_impl
+{
+	axis2_http_simple_request_t simple_request;
+	axis2_http_request_line_t *request_line;
+    axis2_array_list_t *header_group;
+    axis2_stream_t *stream;
+};
+
+#define AXIS2_INTF_TO_IMPL(simple_request) \
+                 ((axis2_http_simple_request_impl_t *)(simple_request))
+
+/***************************** Function headers *******************************/
+
+axis2_http_request_line_t* AXIS2_CALL 
+axis2_http_simple_request_get_request_line
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env);
+
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_request_set_request_line
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env, 
+                        axis2_http_request_line_t *request_line);
+
+axis2_bool_t AXIS2_CALL 
+axis2_http_simple_request_contains_header
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env, axis2_char_t *name);
+
+axis2_array_list_t* AXIS2_CALL 
+axis2_http_simple_request_get_headers
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env);
+
+axis2_http_header_t* AXIS2_CALL 
+axis2_http_simple_request_get_first_header
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env, const axis2_char_t *str);
+
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_request_remove_headers
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env, const axis2_char_t *str);
+
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_request_add_header
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env, axis2_http_header_t *header);
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_simple_request_get_content_type
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env);
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_simple_request_get_charset
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env);
+
+axis2_ssize_t AXIS2_CALL 
+axis2_http_simple_request_get_content_length
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env);
+
+axis2_stream_t* AXIS2_CALL 
+axis2_http_simple_request_get_body(axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env);
+
+axis2_ssize_t AXIS2_CALL 
+axis2_http_simple_request_get_body_bytes
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env, char **buf);
+						
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_request_set_body_string 
+                    (axis2_http_simple_request_t *simple_request, 
+                    axis2_env_t **env, axis2_char_t *str);
+
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_request_free(axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env);
+								
+/***************************** End of function headers ************************/
+
+axis2_http_simple_request_t * AXIS2_CALL 
+axis2_http_simple_request_create 
+                        (axis2_env_t **env,
+                        axis2_http_request_line_t *request_line,
+                        axis2_http_header_t **http_headers,
+                        axis2_ssize_t http_hdr_count,
+                        axis2_stream_t *content)
+{
+    AXIS2_ENV_CHECK(env, NULL);
+    AXIS2_FUNC_PARAM_CHECK(request_line, env, NULL);
+    
+    axis2_http_simple_request_impl_t *simple_request_impl = 
+                        (axis2_http_simple_request_impl_t *)AXIS2_MALLOC 
+                        ((*env)->allocator, sizeof(
+                        axis2_http_simple_request_impl_t));
+	
+    if(NULL == simple_request_impl)
+	{
+		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    simple_request_impl->request_line = request_line;
+    simple_request_impl->stream = content;
+    simple_request_impl->header_group = NULL;
+    if(http_hdr_count > 0 && NULL != http_headers)
+    {
+        simple_request_impl->header_group = axis2_array_list_create(env, 
+                        http_hdr_count);
+        int i = 0;
+        for(i = 0; i < http_hdr_count; i++)
+        {
+            AXIS2_ARRAY_LIST_ADD(simple_request_impl->header_group, env, 
+                        (void*)http_headers[i]);
+        }
+    }
+    /*
+        TODO : handle chunked streams
+    */
+    simple_request_impl->simple_request.ops = AXIS2_MALLOC((*env)->allocator,
+        sizeof(axis2_http_simple_request_ops_t));
+    if(NULL == simple_request_impl->simple_request.ops)
+	{
+		axis2_http_simple_request_free((axis2_http_simple_request_t*)
+                        simple_request_impl, env);
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    
+    simple_request_impl->simple_request.ops->get_request_line = 
+                        axis2_http_simple_request_get_request_line;
+    simple_request_impl->simple_request.ops->set_request_line =
+                        axis2_http_simple_request_set_request_line;
+    simple_request_impl->simple_request.ops->contains_header = 
+                        axis2_http_simple_request_contains_header;
+    simple_request_impl->simple_request.ops->get_headers = 
+                        axis2_http_simple_request_get_headers;
+    simple_request_impl->simple_request.ops->get_first_header =
+                        axis2_http_simple_request_get_first_header;
+    simple_request_impl->simple_request.ops->remove_headers =
+                        axis2_http_simple_request_remove_headers;
+    simple_request_impl->simple_request.ops->add_header = 
+                        axis2_http_simple_request_add_header;
+    simple_request_impl->simple_request.ops->get_content_type =
+                        axis2_http_simple_request_get_content_type;
+    simple_request_impl->simple_request.ops->get_charset =
+                        axis2_http_simple_request_get_charset;
+    simple_request_impl->simple_request.ops->get_content_length =
+                        axis2_http_simple_request_get_content_length;
+    simple_request_impl->simple_request.ops->get_body =
+                        axis2_http_simple_request_get_body;
+    simple_request_impl->simple_request.ops->get_body_bytes =
+                        axis2_http_simple_request_get_body_bytes;
+	simple_request_impl->simple_request.ops->set_body_string =
+						axis2_http_simple_request_set_body_string;
+    simple_request_impl->simple_request.ops->free = 
+                        axis2_http_simple_request_free;
+    
+	return &(simple_request_impl->simple_request);
+}
+
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_request_free(axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env)
+{
+	AXIS2_FUNC_PARAM_CHECK(simple_request, env, AXIS2_FAILURE);
+    axis2_http_simple_request_impl_t *simple_request_impl = 
+                        AXIS2_INTF_TO_IMPL(simple_request);
+    /*
+        Don't free the stream since it belongs to the socket
+        TODO : if chunked remove the chunked stream.
+    */
+    if(NULL != simple_request_impl->request_line)
+    {
+        AXIS2_HTTP_REQUEST_LINE_FREE(simple_request_impl->request_line, env);
+        simple_request_impl->request_line = NULL;
+    }
+    if(NULL != simple_request_impl->header_group)
+    {
+        int i = 0;
+        axis2_http_header_t *tmp = NULL;
+        for(i = 0; i< AXIS2_ARRAY_LIST_SIZE(simple_request_impl->header_group, 
+                        env); i++)
+        {
+            tmp = (axis2_http_header_t *)AXIS2_ARRAY_LIST_REMOVE(
+                            simple_request_impl->header_group, env, i);
+            AXIS2_HTTP_HEADER_FREE(tmp, env);        
+        }
+        AXIS2_ARRAY_LIST_FREE(simple_request_impl->header_group, env);
+        simple_request_impl->header_group = NULL;
+    }
+    
+    if(NULL != simple_request->ops)
+        AXIS2_FREE((*env)->allocator, simple_request->ops);
+    
+	AXIS2_FREE((*env)->allocator, simple_request_impl);
+    
+	return AXIS2_SUCCESS;
+}
+
+axis2_http_request_line_t* AXIS2_CALL 
+axis2_http_simple_request_get_request_line
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_request, env, NULL);
+    return AXIS2_INTF_TO_IMPL(simple_request)->request_line;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_request_set_request_line
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env, 
+                        axis2_http_request_line_t *request_line)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_request, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, request_line, AXIS2_FAILURE);
+    AXIS2_INTF_TO_IMPL(simple_request)->request_line = request_line;
+    return AXIS2_SUCCESS;
+}
+
+
+axis2_bool_t AXIS2_CALL 
+axis2_http_simple_request_contains_header
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env, axis2_char_t *name)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_request, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, name, AXIS2_FAILURE);
+    axis2_http_simple_request_impl_t *simple_request_impl = AXIS2_INTF_TO_IMPL(
+                        simple_request);                 
+    if(NULL == simple_request_impl->header_group)
+    {
+        return AXIS2_FALSE;
+    }
+    int count = AXIS2_ARRAY_LIST_SIZE(simple_request_impl->header_group, env);
+    if(0 == count)
+    {
+        return AXIS2_FALSE;
+    }
+    int i = 0;
+    axis2_char_t *header_name = NULL;
+    for(i = 0; i < count; i++)
+    {
+        header_name = AXIS2_HTTP_HEADER_GET_NAME((axis2_http_header_t *)
+                        AXIS2_ARRAY_LIST_GET(simple_request_impl->header_group,
+                        env, i), env);
+        if(0 == AXIS2_STRCASECMP(name,header_name))
+            return AXIS2_TRUE;            
+    }
+    return AXIS2_FALSE;
+}
+
+
+axis2_array_list_t* AXIS2_CALL 
+axis2_http_simple_request_get_headers
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_request, env, NULL);
+    return AXIS2_INTF_TO_IMPL(simple_request)->header_group;
+}
+
+
+axis2_http_header_t* AXIS2_CALL 
+axis2_http_simple_request_get_first_header
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env, const axis2_char_t *str)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_request, env, NULL);
+    AXIS2_PARAM_CHECK((*env)->error, str, NULL);
+    
+    axis2_http_simple_request_impl_t *simple_request_impl = 
+                        AXIS2_INTF_TO_IMPL(simple_request);
+    
+    axis2_array_list_t *header_group = simple_request_impl->header_group;
+    if(NULL == simple_request_impl->header_group)
+    {
+        return NULL;
+    }
+    if(0 == AXIS2_ARRAY_LIST_SIZE(header_group, env))
+    {
+        return NULL;
+    }
+    
+    int i = 0;
+    int count = AXIS2_ARRAY_LIST_SIZE(header_group, env);
+    axis2_http_header_t *tmp_header = NULL;
+    axis2_char_t *tmp_name = NULL;
+    
+    for(i = 0; i < count; i++)
+    {
+        tmp_header = (axis2_http_header_t *)AXIS2_ARRAY_LIST_GET(header_group, 
+                        env, i);
+        tmp_name = AXIS2_HTTP_HEADER_GET_NAME(tmp_header, env);
+        if(0 == AXIS2_STRCASECMP(str, tmp_name))
+        {
+            return tmp_header;
+        }
+    }
+    return NULL;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_request_remove_headers
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env, const axis2_char_t *str)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_request, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, str, AXIS2_FAILURE);
+    
+    axis2_array_list_t *header_group = AXIS2_INTF_TO_IMPL(simple_request)->
+                        header_group;
+    if(NULL == header_group)
+    {
+        /* Even though we couldn't complete the op, we are sure that the 
+         * requred header is no more in the request. So we can proceed without a
+         * problem.
+         */
+        return AXIS2_SUCCESS;
+    }
+    int i = 0;
+    int count = AXIS2_ARRAY_LIST_SIZE(header_group, env);
+    axis2_http_header_t *tmp_header = NULL;
+    axis2_char_t *tmp_name = NULL;
+    
+    for(i = 0; i < count; i++)
+    {
+        tmp_header = (axis2_http_header_t *)AXIS2_ARRAY_LIST_GET(header_group, 
+                        env, i);
+        tmp_name = AXIS2_HTTP_HEADER_GET_NAME(tmp_header, env);
+        if(0 == AXIS2_STRCASECMP(str, tmp_name))
+        {
+            AXIS2_HTTP_HEADER_FREE(tmp_header, env);
+            AXIS2_ARRAY_LIST_REMOVE(header_group, env, i);
+            break;
+        }
+    }
+    return AXIS2_SUCCESS;    
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_request_add_header
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env, axis2_http_header_t *header)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_request, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, header, AXIS2_FAILURE);
+    
+    axis2_http_simple_request_impl_t *simple_request_impl = AXIS2_INTF_TO_IMPL(
+                        simple_request);
+    if(NULL == simple_request_impl->header_group)
+    {
+        simple_request_impl->header_group = axis2_array_list_create(env, 1);
+    }
+    return AXIS2_ARRAY_LIST_ADD(AXIS2_INTF_TO_IMPL(simple_request)->header_group,
+                        env, header);
+}
+
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_simple_request_get_content_type
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_request, env, NULL);
+    axis2_http_header_t *tmp_header = axis2_http_simple_request_get_first_header
+                        (simple_request, env, AXIS2_HTTP_HEADER_CONTENT_TYPE);
+    if(NULL != tmp_header)
+        return AXIS2_HTTP_HEADER_GET_VALUE(tmp_header, env);
+    
+    return AXIS2_HTTP_HEADER_ACCEPT_TEXT_PLAIN;
+}
+
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_simple_request_get_charset
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_request, env, NULL);
+    axis2_http_header_t *tmp_header = axis2_http_simple_request_get_first_header
+                        (simple_request, env, AXIS2_HTTP_HEADER_CONTENT_TYPE);
+    if(NULL != tmp_header)
+    {
+        axis2_char_t *value = AXIS2_HTTP_HEADER_GET_VALUE(tmp_header, env);
+        axis2_char_t *charset = (axis2_char_t *)strstr((char *)value, 
+                        (char *)AXIS2_HTTP_CHAR_SET_ENCODING);
+        if(NULL != charset)
+        {
+            charset = strchr((char *)charset, '=');
+            return charset;
+        }
+    }
+    
+    return AXIS2_HTTP_DEFAULT_CONTENT_CHARSET;
+}
+
+
+axis2_ssize_t AXIS2_CALL 
+axis2_http_simple_request_get_content_length
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_request, env, AXIS2_FAILURE);
+    axis2_http_header_t *tmp_header = axis2_http_simple_request_get_first_header
+                        (simple_request, env, AXIS2_HTTP_HEADER_CONTENT_LENGTH);
+    if(NULL != tmp_header)
+    {
+        return atoi(AXIS2_HTTP_HEADER_GET_VALUE(tmp_header, env));
+    }
+    return -1;
+}
+
+
+axis2_stream_t* AXIS2_CALL 
+axis2_http_simple_request_get_body(axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_request, env, NULL);
+    return AXIS2_INTF_TO_IMPL(simple_request)->stream;
+}
+
+
+axis2_ssize_t AXIS2_CALL 
+axis2_http_simple_request_get_body_bytes
+                        (axis2_http_simple_request_t *simple_request, 
+                        axis2_env_t **env, char **buf)
+{
+	axis2_stream_t *body = NULL;
+	char *tmp_buf = NULL;
+	char *tmp_buf2 = NULL;
+	char *tmp_buf3 = NULL;
+	int length = 0;
+	int read_len = 0;
+	
+    AXIS2_FUNC_PARAM_CHECK(simple_request, env, AXIS2_FAILURE);
+	
+	body = AXIS2_INTF_TO_IMPL(simple_request)->stream;
+	if(NULL == body)
+	{
+		*buf = (char*)AXIS2_MALLOC((*env)->allocator, 1);
+		*buf[0] = '\0';
+		return 0;
+	}
+	length = AXIS2_HTTP_SIMPLE_REQUEST_GET_CONTENT_LENGTH(simple_request, env);
+	if(length > 0)
+	{
+		*buf = (char*)AXIS2_MALLOC((*env)->allocator, length);
+		read_len = AXIS2_STREAM_READ(body, env, buf, length);
+		return read_len;
+	}
+	tmp_buf2 = AXIS2_MALLOC((*env)->allocator, 128 * sizeof(char));
+	while(AXIS2_STREAM_READ(body, env, tmp_buf2, 128) > 0)
+	{
+		tmp_buf3 = AXIS2_STRACAT(tmp_buf, tmp_buf2, env);
+		if(NULL != tmp_buf)
+		{
+			AXIS2_FREE((*env)->allocator, tmp_buf);
+			tmp_buf = NULL;
+		}
+		tmp_buf = tmp_buf3;
+		
+	}
+    /*
+        TODO :STREAM_READ => STREAM_READ_BYTES
+    */
+	if(NULL != tmp_buf)
+	{
+		*buf = tmp_buf;
+		return AXIS2_STRLEN(tmp_buf);
+	}
+    return -1;    
+}
+
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_request_set_body_string 
+                    (axis2_http_simple_request_t *simple_request, 
+                    axis2_env_t **env, axis2_char_t *str)
+{
+	axis2_stream_t *body_stream = NULL;
+    AXIS2_FUNC_PARAM_CHECK(simple_request, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, str, AXIS2_FAILURE);
+    
+	body_stream = AXIS2_INTF_TO_IMPL(simple_request)->stream;
+	if(NULL == body_stream)
+	{
+		body_stream = axis2_stream_create_basic(env);
+		if(NULL == body_stream)
+		{
+			return AXIS2_FAILURE;
+		}
+		AXIS2_INTF_TO_IMPL(simple_request)->stream = body_stream;
+	}
+	AXIS2_STREAM_WRITE(body_stream, env, str, AXIS2_STRLEN(str));
+    return AXIS2_SUCCESS;
+}

Added: webservices/axis2/trunk/c/modules/core/transport/http/http_simple_response.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/http_simple_response.c?rev=369361&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/http_simple_response.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/http_simple_response.c Sun Jan 15 21:58:47 2006
@@ -0,0 +1,697 @@
+/*
+ * 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_simple_response.h>
+#include <axis2_http_transport.h>
+#include <axis2_string.h>
+#include <stdio.h>
+#include <string.h>
+
+/** 
+ * @brief HTTP Simple Response struct impl
+ *	Axis2 HTTP Simple Response impl  
+ */
+typedef struct axis2_http_simple_response_impl 
+                                        axis2_http_simple_response_impl_t;  
+  
+struct axis2_http_simple_response_impl
+{
+	axis2_http_simple_response_t simple_response;
+	axis2_http_status_line_t *status_line;
+    axis2_array_list_t *header_group;
+    axis2_stream_t *stream;
+};
+
+#define AXIS2_INTF_TO_IMPL(simple_response) \
+                 ((axis2_http_simple_response_impl_t *)(simple_response))
+
+/***************************** Function headers *******************************/
+
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_response_set_status_line 
+                        (struct axis2_http_simple_response *simple_response, 
+                        axis2_env_t **env, const axis2_char_t *http_ver, 
+                        const int status_code, const axis2_char_t *phrase);
+    
+axis2_char_t* AXIS2_CALL 
+axis2_http_simple_response_get_phrase 
+                        (axis2_http_simple_response_t *simple_response, 
+                        axis2_env_t **env);
+    
+int AXIS2_CALL 
+axis2_http_simple_response_get_status_code 
+                        (axis2_http_simple_response_t *simple_response, 
+                        axis2_env_t **env);
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_simple_response_get_http_version 
+                        (axis2_http_simple_response_t *simple_response, 
+                        axis2_env_t **env);
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_simple_response_get_status_line 
+                        (axis2_http_simple_response_t *simple_response, 
+                        axis2_env_t **env);
+
+axis2_bool_t AXIS2_CALL 
+axis2_http_simple_response_contains_header 
+                    (axis2_http_simple_response_t *simple_response, 
+                    axis2_env_t **env, axis2_char_t *name);
+
+axis2_array_list_t* AXIS2_CALL 
+axis2_http_simple_response_get_headers 
+                    (axis2_http_simple_response_t *simple_response, 
+                    axis2_env_t **env);
+    
+axis2_http_header_t* AXIS2_CALL 
+axis2_http_simple_response_get_first_header
+                    (axis2_http_simple_response_t *simple_response, 
+                    axis2_env_t **env, axis2_char_t *str);
+    
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_response_remove_headers 
+                    (axis2_http_simple_response_t *simple_response, 
+                    axis2_env_t **env, const axis2_char_t *str);
+    
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_response_set_header 
+                    (axis2_http_simple_response_t *simple_response, 
+                    axis2_env_t **env, axis2_http_header_t* header);
+    
+axis2_char_t* AXIS2_CALL 
+axis2_http_simple_response_get_charset
+                    (axis2_http_simple_response_t *simple_response, 
+                    axis2_env_t **env);
+    
+axis2_ssize_t AXIS2_CALL 
+axis2_http_simple_response_get_content_length
+                    (axis2_http_simple_response_t *simple_response, 
+                    axis2_env_t **env);
+    
+axis2_char_t* AXIS2_CALL 
+axis2_http_simple_response_get_content_type
+                    (axis2_http_simple_response_t *simple_response, 
+                    axis2_env_t **env);
+
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_response_set_body_string 
+                    (axis2_http_simple_response_t *simple_response, 
+                    axis2_env_t **env, axis2_char_t *str);
+    
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_response_set_body_stream
+                    (axis2_http_simple_response_t *simple_response, 
+                    axis2_env_t **env, axis2_stream_t *stream);    
+
+axis2_stream_t* AXIS2_CALL 
+axis2_http_simple_response_get_body
+                    (axis2_http_simple_response_t *simple_response, 
+                    axis2_env_t **env);
+
+axis2_ssize_t AXIS2_CALL 
+axis2_http_simple_response_get_body_bytes 
+                    (axis2_http_simple_response_t *simple_response, 
+                    axis2_env_t **env, axis2_char_t **buf);
+
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_response_free (axis2_http_simple_response_t *simple_response, 
+                    axis2_env_t **env);
+								
+/***************************** End of function headers ************************/
+
+axis2_http_simple_response_t *AXIS2_CALL
+axis2_http_simple_response_create (axis2_env_t **env,
+                        axis2_http_status_line_t *status_line,
+                        const axis2_http_header_t **http_headers,
+                        const axis2_ssize_t http_hdr_count,
+                        axis2_stream_t *content)
+{
+    AXIS2_ENV_CHECK(env, NULL);
+    AXIS2_FUNC_PARAM_CHECK(status_line, env, NULL);
+    
+    axis2_http_simple_response_t *ret = 
+                        axis2_http_simple_response_create_default(env);
+    if(NULL == ret)
+    {
+        return NULL;
+    }
+    axis2_http_simple_response_impl_t *simple_response_impl =
+                        AXIS2_INTF_TO_IMPL(ret);
+    if(NULL == simple_response_impl)
+	{
+		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    simple_response_impl->status_line = status_line;
+    if(http_hdr_count > 0 && NULL != http_headers)
+    {
+        simple_response_impl->header_group = axis2_array_list_create(env, 
+                        http_hdr_count);
+        int i = 0;
+        for(i = 0; i < http_hdr_count; i++)
+        {
+            AXIS2_ARRAY_LIST_ADD(simple_response_impl->header_group, env, 
+                        (void*)http_headers[i]);
+        }
+    }
+    simple_response_impl->stream = content;
+    
+    return ret;
+}
+
+
+axis2_http_simple_response_t * AXIS2_CALL
+axis2_http_simple_response_create_default(axis2_env_t **env)
+{
+    AXIS2_ENV_CHECK(env, NULL);
+    
+    axis2_http_simple_response_impl_t *simple_response_impl = 
+                        (axis2_http_simple_response_impl_t *)AXIS2_MALLOC 
+                        ((*env)->allocator, sizeof(
+                        axis2_http_simple_response_impl_t));
+    
+    simple_response_impl->simple_response.ops = AXIS2_MALLOC((*env)->allocator,
+                        sizeof(axis2_http_simple_response_ops_t));
+    if(NULL == simple_response_impl->simple_response.ops)
+	{
+		axis2_http_simple_response_free((axis2_http_simple_response_t*)
+                                        simple_response_impl, env);
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+	simple_response_impl->status_line = NULL;
+	simple_response_impl->header_group = NULL;
+	simple_response_impl->stream = NULL;
+	
+    simple_response_impl->simple_response.ops->set_status_line = 
+                        axis2_http_simple_response_set_status_line;
+    simple_response_impl->simple_response.ops->get_phrase =
+                        axis2_http_simple_response_get_phrase;
+    simple_response_impl->simple_response.ops->get_status_code = 
+                        axis2_http_simple_response_get_status_code;
+    simple_response_impl->simple_response.ops->get_http_version = 
+                        axis2_http_simple_response_get_http_version;
+    simple_response_impl->simple_response.ops->get_status_line =
+                        axis2_http_simple_response_get_status_line;
+    simple_response_impl->simple_response.ops->contains_header =
+                        axis2_http_simple_response_contains_header;
+    simple_response_impl->simple_response.ops->get_headers =
+                        axis2_http_simple_response_get_headers;
+    simple_response_impl->simple_response.ops->get_first_header =
+                        axis2_http_simple_response_get_first_header;
+    simple_response_impl->simple_response.ops->remove_headers =
+                        axis2_http_simple_response_remove_headers;
+    simple_response_impl->simple_response.ops->set_header = 
+                        axis2_http_simple_response_set_header;
+    simple_response_impl->simple_response.ops->get_charset =
+                        axis2_http_simple_response_get_charset;
+    simple_response_impl->simple_response.ops->get_content_type =
+                        axis2_http_simple_response_get_content_type;
+    simple_response_impl->simple_response.ops->get_content_length =
+                        axis2_http_simple_response_get_content_length;
+    simple_response_impl->simple_response.ops->set_body_string =               
+                        axis2_http_simple_response_set_body_string;
+    simple_response_impl->simple_response.ops->set_body_stream = 
+                        axis2_http_simple_response_set_body_stream;                        
+    simple_response_impl->simple_response.ops->get_body =
+                        axis2_http_simple_response_get_body;
+    simple_response_impl->simple_response.ops->get_body_bytes =
+                        axis2_http_simple_response_get_body_bytes;
+    simple_response_impl->simple_response.ops->free = 
+                        axis2_http_simple_response_free;
+    
+	return &(simple_response_impl->simple_response);
+}
+
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_response_free (axis2_http_simple_response_t *simple_response, 
+                    axis2_env_t **env)
+{
+	AXIS2_FUNC_PARAM_CHECK(simple_response, env, AXIS2_FAILURE);
+    axis2_http_simple_response_impl_t *simple_response_impl = 
+                        AXIS2_INTF_TO_IMPL(simple_response);
+    if(NULL != simple_response_impl->status_line)
+    {
+        AXIS2_HTTP_STATUS_LINE_FREE(simple_response_impl->status_line, env);
+        simple_response_impl->status_line = NULL;
+    }
+    if(NULL != simple_response_impl->header_group)
+    {
+        int i = 0;
+        axis2_http_header_t *tmp = NULL;
+        for(i = 0; i< AXIS2_ARRAY_LIST_SIZE(simple_response_impl->header_group, 
+                        env); i++)
+        {
+            tmp = (axis2_http_header_t *)AXIS2_ARRAY_LIST_GET(
+                            simple_response_impl->header_group, env, i);
+			if(NULL != tmp)
+			{
+            	AXIS2_HTTP_HEADER_FREE(tmp, env);        
+			}
+        }
+        AXIS2_ARRAY_LIST_FREE(simple_response_impl->header_group, env);
+        simple_response_impl->header_group = NULL;
+    }
+    if(NULL != simple_response->ops)
+        AXIS2_FREE((*env)->allocator, simple_response->ops);
+    
+	AXIS2_FREE((*env)->allocator, AXIS2_INTF_TO_IMPL(simple_response));
+    /* Stream is not freed
+     * Assumption : stream doesn't belong to the response
+     */
+	return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_response_set_status_line 
+                        (struct axis2_http_simple_response *simple_response, 
+                        axis2_env_t **env, const axis2_char_t *http_ver, 
+                        const int status_code, const axis2_char_t *phrase)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_response, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, http_ver, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, status_code, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, phrase, AXIS2_FAILURE);
+    
+    axis2_char_t *tmp_status_line_str = AXIS2_MALLOC((*env)->allocator, 
+                        (AXIS2_STRLEN(http_ver) + AXIS2_STRLEN(phrase) + 8) *
+                        sizeof(axis2_char_t *));
+    sprintf(tmp_status_line_str, "%s %3d %s%s", http_ver, status_code, phrase,
+                        AXIS2_HTTP_CRLF);
+    axis2_http_simple_response_impl_t *simple_response_impl = AXIS2_INTF_TO_IMPL
+                        (simple_response);
+    if(NULL != simple_response_impl->status_line)
+    {
+        AXIS2_HTTP_STATUS_LINE_FREE(simple_response_impl->status_line, env);
+        simple_response_impl->status_line = NULL;
+    }
+    simple_response_impl->status_line = axis2_http_status_line_create(env, 
+                        tmp_status_line_str);
+    AXIS2_FREE((*env)->allocator, tmp_status_line_str);
+    
+    if(NULL == simple_response_impl->status_line)
+    {
+        return AXIS2_FAILURE;
+    }
+    return AXIS2_SUCCESS;
+}
+
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_simple_response_get_phrase 
+                        (axis2_http_simple_response_t *simple_response, 
+                        axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_response, env, NULL);
+    if(NULL == AXIS2_INTF_TO_IMPL(simple_response)->status_line)
+    {
+        return NULL;
+    }
+    return AXIS2_HTTP_STATUS_LINE_GET_REASON_PHRASE(AXIS2_INTF_TO_IMPL(
+                        simple_response)->status_line, env);
+}
+
+
+int AXIS2_CALL 
+axis2_http_simple_response_get_status_code 
+                        (axis2_http_simple_response_t *simple_response, 
+                        axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_response, env, AXIS2_FAILURE);
+    if(NULL == AXIS2_INTF_TO_IMPL(simple_response)->status_line)
+    {
+        return -1;
+    }
+    return AXIS2_HTTP_STATUS_LINE_GET_STATUS_CODE(AXIS2_INTF_TO_IMPL(
+                        simple_response)->status_line, env);
+}
+
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_simple_response_get_http_version 
+                        (axis2_http_simple_response_t *simple_response, 
+                        axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_response, env, NULL);
+    if(NULL == AXIS2_INTF_TO_IMPL(simple_response)->status_line)
+    {
+        return NULL;
+    }
+    return AXIS2_HTTP_STATUS_LINE_GET_HTTP_VERSION(AXIS2_INTF_TO_IMPL(
+                        simple_response)->status_line, env);
+}
+
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_simple_response_get_status_line 
+                        (axis2_http_simple_response_t *simple_response, 
+                        axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_response, env, NULL);
+    if(NULL == AXIS2_INTF_TO_IMPL(simple_response)->status_line)
+    {
+        return NULL;
+    }
+    return AXIS2_HTTP_STATUS_LINE_TO_STRING(AXIS2_INTF_TO_IMPL(
+                        simple_response)->status_line, env);
+}
+
+
+axis2_array_list_t* AXIS2_CALL 
+axis2_http_simple_response_get_headers
+                        (axis2_http_simple_response_t *simple_response, 
+                        axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_response, env, NULL);
+    return AXIS2_INTF_TO_IMPL(simple_response)->header_group;
+}
+
+
+axis2_http_header_t* AXIS2_CALL 
+axis2_http_simple_response_get_first_header
+                        (axis2_http_simple_response_t *simple_response, 
+                        axis2_env_t **env, axis2_char_t *str)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_response, env, NULL);
+    AXIS2_PARAM_CHECK((*env)->error, str, NULL);
+    
+    axis2_http_simple_response_impl_t *simple_response_impl = 
+                        AXIS2_INTF_TO_IMPL(simple_response);
+    
+    axis2_array_list_t *header_group = simple_response_impl->header_group;
+    if(NULL == simple_response_impl->header_group)
+    {
+        return NULL;
+    }
+    if(0 == AXIS2_ARRAY_LIST_SIZE(header_group, env))
+    {
+        return NULL;
+    }
+    
+    int i = 0;
+    int count = AXIS2_ARRAY_LIST_SIZE(header_group, env);
+    axis2_http_header_t *tmp_header = NULL;
+    axis2_char_t *tmp_name = NULL;
+    
+    for(i = 0; i < count; i++)
+    {
+        tmp_header = (axis2_http_header_t *)AXIS2_ARRAY_LIST_GET(header_group, 
+                        env, i);
+        tmp_name = AXIS2_HTTP_HEADER_GET_NAME(tmp_header, env);
+        if(0 == AXIS2_STRCASECMP(str, tmp_name))
+        {
+            return tmp_header;
+        }
+    }
+    return NULL;
+
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_response_remove_headers
+                        (axis2_http_simple_response_t *simple_response, 
+                        axis2_env_t **env, const axis2_char_t *str)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_response, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, str, AXIS2_FAILURE);
+    
+    axis2_array_list_t *header_group = AXIS2_INTF_TO_IMPL(simple_response)->
+                        header_group;
+    if(NULL == header_group)
+    {
+        /* Even though we couldn't complete the op, we are sure that the 
+         * requred header is no more in the request. So we can proceed without a
+         * problem.
+         */
+        return AXIS2_SUCCESS;
+    }
+    int i = 0;
+    int count = AXIS2_ARRAY_LIST_SIZE(header_group, env);
+    axis2_http_header_t *tmp_header = NULL;
+    axis2_char_t *tmp_name = NULL;
+    
+    for(i = 0; i < count; i++)
+    {
+        tmp_header = (axis2_http_header_t *)AXIS2_ARRAY_LIST_GET(header_group, 
+                        env, i);
+        tmp_name = AXIS2_HTTP_HEADER_GET_NAME(tmp_header, env);
+        if(0 == AXIS2_STRCASECMP(str, tmp_name))
+        {
+            AXIS2_HTTP_HEADER_FREE(tmp_header, env);
+            AXIS2_ARRAY_LIST_REMOVE(header_group, env, i);
+            break;
+        }
+    }
+    return AXIS2_SUCCESS;    
+}
+
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_response_set_header 
+                    (axis2_http_simple_response_t *simple_response, 
+                    axis2_env_t **env, axis2_http_header_t* header)
+{
+	int i = 0;
+	int count = 0;
+    axis2_http_header_t *tmp_header = NULL;
+    axis2_char_t *tmp_name = NULL;
+	axis2_array_list_t *header_group = NULL;
+	
+    AXIS2_FUNC_PARAM_CHECK(simple_response, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, header, AXIS2_FAILURE);
+    
+    axis2_http_simple_response_impl_t *simple_response_impl = AXIS2_INTF_TO_IMPL
+                    (simple_response);
+    
+    if(NULL == simple_response_impl->header_group)
+    {
+        simple_response_impl->header_group = axis2_array_list_create(env, 10);
+        AXIS2_ARRAY_LIST_ADD(simple_response_impl->header_group, env, header);
+        return AXIS2_SUCCESS;
+    }
+    
+    /* If a header with the same name exists
+     * search and remove the old header
+     */
+    header_group = AXIS2_INTF_TO_IMPL(simple_response)->header_group;
+    
+    count = AXIS2_ARRAY_LIST_SIZE(header_group, env);
+    for(i = 0; i < count; i++)
+    {
+        tmp_header = (axis2_http_header_t *)AXIS2_ARRAY_LIST_GET(header_group, 
+                        env, i);
+        tmp_name = AXIS2_HTTP_HEADER_GET_NAME(tmp_header, env);
+        if(0 == AXIS2_STRCASECMP(AXIS2_HTTP_HEADER_GET_NAME(header, env), 
+                                tmp_name))
+        {
+            AXIS2_HTTP_HEADER_FREE(tmp_header, env);
+            AXIS2_ARRAY_LIST_REMOVE(header_group, env, i);
+            break;
+        }
+    }
+	AXIS2_ARRAY_LIST_ADD(simple_response_impl->header_group, env, 
+						(void*)header);
+    return AXIS2_SUCCESS;
+}
+
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_simple_response_get_charset
+                        (axis2_http_simple_response_t *simple_response, 
+                        axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_response, env, NULL);
+    axis2_http_header_t *tmp_header = axis2_http_simple_response_get_first_header
+                        (simple_response, env, AXIS2_HTTP_HEADER_CONTENT_TYPE);
+    if(NULL != tmp_header)
+    {
+        axis2_char_t *value = AXIS2_HTTP_HEADER_GET_VALUE(tmp_header, env);
+        axis2_char_t *charset = (axis2_char_t *)strstr((char *)value, 
+                        (char *)AXIS2_HTTP_CHAR_SET_ENCODING);
+        if(NULL != charset)
+        {
+            charset = strchr((char *)charset, '=');
+            return charset;
+        }
+    }
+    
+    return AXIS2_HTTP_DEFAULT_CONTENT_CHARSET;
+}
+
+
+axis2_ssize_t AXIS2_CALL 
+axis2_http_simple_response_get_content_length
+                        (axis2_http_simple_response_t *simple_response, 
+                        axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_response, env, AXIS2_FAILURE);
+    axis2_http_header_t *tmp_header = 
+                        axis2_http_simple_response_get_first_header
+                        (simple_response, env, AXIS2_HTTP_HEADER_CONTENT_LENGTH);
+    if(NULL != tmp_header)
+    {
+        return atoi(AXIS2_HTTP_HEADER_GET_VALUE(tmp_header, env));
+    }
+    return -1;
+}
+
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_simple_response_get_content_type
+                        (axis2_http_simple_response_t *simple_response, 
+                        axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_response, env, NULL);
+    axis2_http_header_t *tmp_header = 
+                        axis2_http_simple_response_get_first_header
+                        (simple_response, env, AXIS2_HTTP_HEADER_CONTENT_TYPE);
+    if(NULL != tmp_header)
+        return AXIS2_HTTP_HEADER_GET_VALUE(tmp_header, env);
+    
+    return AXIS2_HTTP_HEADER_ACCEPT_TEXT_PLAIN;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_response_set_body_string 
+                    (axis2_http_simple_response_t *simple_response, 
+                    axis2_env_t **env, axis2_char_t *str)
+{
+	axis2_stream_t *body_stream = NULL;
+    AXIS2_FUNC_PARAM_CHECK(simple_response, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, str, AXIS2_FAILURE);
+    
+	body_stream = AXIS2_INTF_TO_IMPL(simple_response)->stream;
+	if(NULL == body_stream)
+	{
+		body_stream = axis2_stream_create_basic(env);
+		if(NULL == body_stream)
+		{
+			return AXIS2_FAILURE;
+		}
+		AXIS2_INTF_TO_IMPL(simple_response)->stream = body_stream;
+	}
+	AXIS2_STREAM_WRITE(body_stream, env, str, AXIS2_STRLEN(str));
+    return AXIS2_SUCCESS;
+}
+    
+axis2_status_t AXIS2_CALL 
+axis2_http_simple_response_set_body_stream
+                    (axis2_http_simple_response_t *simple_response, 
+                    axis2_env_t **env, axis2_stream_t *stream)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_response, env, AXIS2_FAILURE);
+    /*
+     * We don't free the stream
+     * Problem in freeing is most of the time the stream doesn't belong
+     * to the http_simple_response
+     */
+    AXIS2_INTF_TO_IMPL(simple_response)->stream = stream;
+    return AXIS2_SUCCESS;
+}
+
+
+
+axis2_stream_t* AXIS2_CALL 
+axis2_http_simple_response_get_body
+                        (axis2_http_simple_response_t *simple_response, 
+                        axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_response, env, NULL);
+    return AXIS2_INTF_TO_IMPL(simple_response)->stream;
+}
+
+
+axis2_ssize_t AXIS2_CALL 
+axis2_http_simple_response_get_body_bytes
+                        (axis2_http_simple_response_t *simple_response, 
+                        axis2_env_t **env, axis2_char_t **buffer)
+{
+	axis2_http_simple_response_impl_t *response_impl = NULL;
+	axis2_stream_t *tmp_stream = NULL;
+	AXIS2_FUNC_PARAM_CHECK(simple_response, env, AXIS2_FAILURE);
+	int return_size = -1;
+	
+	response_impl = AXIS2_INTF_TO_IMPL(simple_response);
+    if(NULL == response_impl->stream)
+	{
+		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NULL_BODY, AXIS2_FAILURE);
+		return -1;
+	}
+	tmp_stream = axis2_stream_create_basic(env);
+	while(1)
+	{
+		int read = 0;
+		int write = 0;
+		int READ_SIZE = 32;
+		char buf[READ_SIZE];
+		read = AXIS2_STREAM_READ(response_impl->stream, env, buf, READ_SIZE);
+		if(read < 0)
+		{
+			break;
+		}
+		write = AXIS2_STREAM_WRITE(tmp_stream, env, buf, read);
+		if(read < READ_SIZE)
+		{
+			break;
+		}
+	}
+	return_size = AXIS2_STREAM_BASIC_GET_LEN(tmp_stream, env);
+	
+	if(return_size > 0)
+	{
+		*buffer = (char *)AXIS2_MALLOC((*env)->allocator, sizeof(char)*
+						(return_size +1));
+		return_size = AXIS2_STREAM_READ(tmp_stream, env, *buffer, 
+						return_size + 1);
+	}
+	AXIS2_STREAM_FREE(tmp_stream, env);
+    return return_size;    
+}
+
+axis2_bool_t AXIS2_CALL 
+axis2_http_simple_response_contains_header 
+                    (axis2_http_simple_response_t *simple_response, 
+                    axis2_env_t **env, axis2_char_t *name)
+{
+    axis2_char_t *header_name = NULL;
+	axis2_http_simple_response_impl_t *simple_response_impl = NULL;
+	int count = 0;
+	int i = 0;
+	
+	AXIS2_FUNC_PARAM_CHECK(simple_response, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, name, AXIS2_FAILURE);
+    simple_response_impl = AXIS2_INTF_TO_IMPL(
+                        simple_response);                 
+    if(NULL == simple_response_impl->header_group)
+    {
+        return AXIS2_FALSE;
+    }
+    count = AXIS2_ARRAY_LIST_SIZE(simple_response_impl->header_group, env);
+    if(0 == count)
+    {
+        return AXIS2_FALSE;
+    }
+        
+    for(i = 0; i < count; i++)
+    {
+        header_name = AXIS2_HTTP_HEADER_GET_NAME((axis2_http_header_t *)
+                        AXIS2_ARRAY_LIST_GET(simple_response_impl->header_group,
+                        env, i), env);
+        if(0 == AXIS2_STRCASECMP(name,header_name))
+            return AXIS2_TRUE;            
+    }
+    return AXIS2_FALSE;
+}

Added: webservices/axis2/trunk/c/modules/core/transport/http/http_status_line.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/http_status_line.c?rev=369361&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/http_status_line.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/http_status_line.c Sun Jan 15 21:58:47 2006
@@ -0,0 +1,275 @@
+/*
+ * 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_status_line.h>
+#include <axis2_string.h>
+#include <axis2_http_transport.h>
+#include <string.h>
+
+/** 
+ * @brief HTTP Status Line struct impl
+ *	Axis2 HTTP Status Line impl  
+ */
+typedef struct axis2_http_status_line_impl axis2_http_status_line_impl_t;  
+  
+struct axis2_http_status_line_impl
+{
+	axis2_http_status_line_t status_line;
+    axis2_char_t *line;
+	axis2_char_t *http_version;
+    axis2_char_t *status_code;
+    axis2_char_t *reason_phrase;
+};
+
+#define AXIS2_INTF_TO_IMPL(status_line) \
+                    ((axis2_http_status_line_impl_t *)(status_line))
+
+/***************************** Function headers *******************************/
+int AXIS2_CALL 
+axis2_http_status_line_get_status_code (axis2_http_status_line_t *status_line, 
+                    axis2_env_t **env);
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_status_line_get_http_version (axis2_http_status_line_t *status_line, 
+                    axis2_env_t **env);
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_status_line_get_reason_phrase (axis2_http_status_line_t *status_line,
+                    axis2_env_t **env);
+
+axis2_bool_t AXIS2_CALL 
+axis2_http_status_line_starts_with_http (axis2_http_status_line_t *status_line, 
+                    axis2_env_t **env);
+
+axis2_char_t *AXIS2_CALL
+axis2_http_status_line_to_string (axis2_http_status_line_t *status_line, 
+                    axis2_env_t **env);
+
+axis2_status_t AXIS2_CALL 
+axis2_http_status_line_free (axis2_http_status_line_t *status_line, 
+                                    axis2_env_t **env);	
+/***************************** End of function headers ************************/
+
+axis2_http_status_line_t * AXIS2_CALL 
+axis2_http_status_line_create(axis2_env_t **env, axis2_char_t *str)
+{
+    AXIS2_ENV_CHECK(env, NULL);
+    AXIS2_FUNC_PARAM_CHECK(str, env, NULL);
+    axis2_char_t *tmp_status_line = NULL;
+    axis2_char_t *reason_phrase = NULL;
+    axis2_char_t *status_code= NULL;
+    axis2_char_t *http_version = NULL;
+    int i = 0;
+    axis2_char_t *tmp = NULL;
+    
+    axis2_http_status_line_impl_t *status_line_impl = 
+                        (axis2_http_status_line_impl_t *)AXIS2_MALLOC 
+                        ((*env)->allocator, sizeof(
+                        axis2_http_status_line_impl_t));
+	
+    if(NULL == status_line_impl)
+	{
+		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    status_line_impl->line = (axis2_char_t *)AXIS2_STRDUP(str, env);
+    status_line_impl->http_version = NULL;
+    status_line_impl->reason_phrase = NULL;
+    
+    
+    tmp = strstr(str, AXIS2_HTTP_CRLF);
+    if(NULL == tmp)
+    {
+        axis2_http_status_line_free((axis2_http_status_line_t*)
+                         status_line_impl, env);
+        AXIS2_ERROR_SET((*env)->error, 
+                        AXIS2_ERROR_INVALID_HTTP_INVALID_HEADER_START_LINE, 
+                        AXIS2_FAILURE);
+        return NULL;
+    }
+    i = tmp - str;
+    tmp_status_line = AXIS2_MALLOC((*env)->allocator, 
+                        i * sizeof(axis2_char_t) +1);
+    if(NULL == tmp_status_line)
+    {
+        axis2_http_status_line_free((axis2_http_status_line_t*)
+                         status_line_impl, env);
+       AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); 
+       return NULL;
+    }
+    memcpy(tmp_status_line, str, i * sizeof(axis2_char_t));
+    tmp_status_line[i] = '\0';
+    tmp = tmp_status_line;
+    
+    http_version = tmp;
+    tmp = strchr(tmp, ' ');
+    if(NULL == tmp)
+    {
+        AXIS2_FREE((*env)->allocator, tmp_status_line);
+        axis2_http_status_line_free((axis2_http_status_line_t*)
+                         status_line_impl, env);
+        AXIS2_ERROR_SET((*env)->error, 
+                        AXIS2_ERROR_INVALID_HTTP_INVALID_HEADER_START_LINE, 
+                        AXIS2_FAILURE);
+        return NULL;
+    }
+    *tmp++ = '\0';
+    status_code = tmp;
+    tmp = strchr(tmp, ' ');
+    if(NULL == tmp)
+    {
+        AXIS2_FREE((*env)->allocator, tmp_status_line);
+        axis2_http_status_line_free((axis2_http_status_line_t*)
+                         status_line_impl, env);
+        AXIS2_ERROR_SET((*env)->error, 
+                        AXIS2_ERROR_INVALID_HTTP_INVALID_HEADER_START_LINE, 
+                        AXIS2_FAILURE);
+        return NULL;
+    }
+    *tmp++ = '\0';
+    reason_phrase = tmp;
+    status_line_impl->http_version = (axis2_char_t *)
+                        AXIS2_STRDUP(http_version, env);
+    status_line_impl->status_code = (axis2_char_t *)
+                        AXIS2_STRDUP(status_code, env);
+    status_line_impl->reason_phrase = (axis2_char_t *)
+                        AXIS2_STRDUP(reason_phrase, env);
+    
+    if(NULL == status_line_impl->http_version || 
+                        NULL == status_line_impl->reason_phrase)
+    {
+        AXIS2_FREE((*env)->allocator, tmp_status_line);
+        axis2_http_status_line_free((axis2_http_status_line_t*)
+                         status_line_impl, env);
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+    }
+    AXIS2_FREE((*env)->allocator, tmp_status_line);
+    
+    status_line_impl->status_line.ops = AXIS2_MALLOC((*env)->allocator,
+                        sizeof(axis2_http_status_line_ops_t));
+    if(NULL == status_line_impl->status_line.ops)
+	{
+		axis2_http_status_line_free((axis2_http_status_line_t*)
+                         status_line_impl, env);
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    
+    status_line_impl->status_line.ops->get_status_code =
+                        axis2_http_status_line_get_status_code;
+    status_line_impl->status_line.ops->get_http_version =
+                        axis2_http_status_line_get_http_version;
+    status_line_impl->status_line.ops->get_reason_phrase =
+                        axis2_http_status_line_get_reason_phrase;
+    status_line_impl->status_line.ops->starts_with_http =
+                        axis2_http_status_line_starts_with_http;
+    status_line_impl->status_line.ops->to_string =
+                        axis2_http_status_line_to_string;
+    status_line_impl->status_line.ops->free =
+                        axis2_http_status_line_free;
+	return &(status_line_impl->status_line);
+}
+
+axis2_status_t AXIS2_CALL 
+axis2_http_status_line_free (axis2_http_status_line_t *status_line, 
+                                    axis2_env_t **env)
+{
+	AXIS2_FUNC_PARAM_CHECK(status_line, env, AXIS2_FAILURE);
+    axis2_http_status_line_impl_t *status_line_impl =
+                        AXIS2_INTF_TO_IMPL(status_line);
+    if(NULL != status_line_impl->line)
+    {
+        AXIS2_FREE((*env)->allocator, status_line_impl->line);
+        status_line_impl->line = NULL;
+    }
+    if(NULL != status_line_impl->http_version)
+    {
+        AXIS2_FREE((*env)->allocator, status_line_impl->http_version);
+        status_line_impl->http_version = NULL;
+    }
+    if(NULL != status_line_impl->status_code)
+    {
+        AXIS2_FREE((*env)->allocator, status_line_impl->status_code);
+        status_line_impl->status_code = NULL;
+    }
+    if(NULL != status_line_impl->reason_phrase)
+    {
+        AXIS2_FREE((*env)->allocator, status_line_impl->reason_phrase);
+        status_line_impl->reason_phrase = NULL;
+    }     
+    if(NULL != status_line->ops)
+        AXIS2_FREE((*env)->allocator, status_line->ops);
+    
+	AXIS2_FREE((*env)->allocator, AXIS2_INTF_TO_IMPL(status_line));
+	return AXIS2_SUCCESS;
+}
+
+
+int AXIS2_CALL 
+axis2_http_status_line_get_status_code (axis2_http_status_line_t *status_line, 
+                    axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(status_line, env, AXIS2_CRTICAL_FAILURE);
+    if(NULL != AXIS2_INTF_TO_IMPL(status_line)->status_code)
+    {
+        return atoi(AXIS2_INTF_TO_IMPL(status_line)->status_code);
+    }
+    else
+    {
+        return AXIS2_CRTICAL_FAILURE;
+    }
+    
+}
+
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_status_line_get_http_version (axis2_http_status_line_t *status_line, 
+                    axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(status_line, env, NULL);
+    return AXIS2_INTF_TO_IMPL(status_line)->http_version;
+}
+
+
+axis2_char_t* AXIS2_CALL 
+axis2_http_status_line_get_reason_phrase (axis2_http_status_line_t *status_line,
+                    axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(status_line, env, NULL);
+    return AXIS2_INTF_TO_IMPL(status_line)->reason_phrase;
+}
+
+
+axis2_bool_t AXIS2_CALL 
+axis2_http_status_line_starts_with_http (axis2_http_status_line_t *status_line, 
+                    axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(status_line, env, AXIS2_FAILURE);
+    if(0 == AXIS2_STRNCASECMP(AXIS2_INTF_TO_IMPL(status_line)->line, "HTTP", 4))
+    {
+        return AXIS2_TRUE;
+    }
+    return AXIS2_FALSE;
+}
+
+axis2_char_t *AXIS2_CALL
+axis2_http_status_line_to_string (axis2_http_status_line_t *status_line, 
+                    axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(status_line, env, NULL);
+    return AXIS2_INTF_TO_IMPL(status_line)->line;
+}



Mime
View raw message