axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam...@apache.org
Subject svn commit: r356461 [2/2] - in /webservices/axis2/trunk/c/modules/core/transport/http: ./ src/ src/.deps/
Date Tue, 13 Dec 2005 03:44:37 GMT
Added: webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_simple_response.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_simple_response.c?rev=356461&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_simple_response.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_simple_response.c Mon Dec 12 19:44:22 2005
@@ -0,0 +1,606 @@
+/*
+ * 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, 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, 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_REMOVE(
+                            simple_response_impl->header_group, env, i);
+            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 reaponse
+     */
+	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 operation, 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)
+{
+    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, 1);
+        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
+     */
+    axis2_array_list_t *header_group = AXIS2_INTF_TO_IMPL(simple_response)->
+                        header_group;
+    int i = 0;
+    axis2_http_header_t *tmp_header = NULL;
+    axis2_char_t *tmp_name = NULL;
+    int 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, 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_FUNC_PARAM_CHECK(simple_response, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, str, AXIS2_FAILURE);
+    /*
+        TODO stream dependent
+    */
+    
+    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);
+    AXIS2_PARAM_CHECK((*env)->error, stream, AXIS2_FAILURE);
+    /*
+     * TODO do we have to free the existing 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 *buf)
+{
+    AXIS2_FUNC_PARAM_CHECK(simple_response, env, AXIS2_FAILURE);
+    /*
+        TODO stream dependent
+    */
+    return -1;    
+}

Added: webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_status_line.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_status_line.c?rev=356461&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_status_line.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_status_line.c Mon Dec 12 19:44:22 2005
@@ -0,0 +1,268 @@
+/*
+ * 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, 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, 
+                        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, 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, 
+                        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, 
+                        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, 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, 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;
+}

Added: webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_transport_utils.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_transport_utils.c?rev=356461&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_transport_utils.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_transport_utils.c Mon Dec 12 19:44:22 2005
@@ -0,0 +1,148 @@
+/*
+ * 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>
+
+/***************************** 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 *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 *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);
+                                
+/***************************** 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 *stream, axis2_char_t *content_type, 
+                        axis2_char_t *soap_action_header,
+                        axis2_char_t *request_uri)
+{
+    /*
+        TODO code
+    */
+    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 *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)
+{
+    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)
+{
+    return NULL;
+}
+
+
+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)
+{
+    return NULL;
+}
+
+
+axis2_bool_t AXIS2_CALL 
+axis2_http_transport_utils_is_optimized(axis2_env_t **env, 
+                                        axis2_om_element_t *om_element)
+{
+    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;
+}

Added: webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_worker.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_worker.c?rev=356461&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_worker.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_worker.c Mon Dec 12 19:44:22 2005
@@ -0,0 +1,216 @@
+/*
+ * 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>
+
+/** 
+ * @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_trasnport_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_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, 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, NULL);
+	}
+    
+    http_worker_impl->http_worker.ops->process_request = 
+                                    axis2_http_worker_process_request;
+    http_worker_impl->http_worker.ops->set_response_headers = 
+                                    axis2_http_worker_set_response_headers;
+    http_worker_impl->http_worker.ops->set_trasnport_out_config =
+                                    axis2_http_worker_set_trasnport_out_config;
+    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_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);
+    /*
+        TODO create the engine and process the request
+    */
+    return AXIS2_TRUE;
+}
+
+
+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_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))
+    {
+        axis2_http_header_t *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];
+                sprintf(content_len_str, "%10d", content_length);
+                axis2_http_header_t *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;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_worker_set_trasnport_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_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);
+
+    /*
+        TODO implement the method
+    */
+    return AXIS2_SUCCESS;
+}

Added: webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_simple_http_svr_conn.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_simple_http_svr_conn.c?rev=356461&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_simple_http_svr_conn.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_simple_http_svr_conn.c Mon Dec 12 19:44:22 2005
@@ -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_simple_http_svr_conn.h>
+#include <unistd.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, 
+                                const 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, NULL);
+    }
+    svr_conn_impl->socket = sockfd;
+    svr_conn_impl->stream = NULL;
+    svr_conn_impl->keep_alive = AXIS2_FALSE;
+    
+    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, 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_FUNC_PARAM_CHECK(svr_conn, env, NULL);
+    /*
+        TODO stream dependant code
+    */
+    return NULL;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_simple_http_svr_conn_write_response
+                                (axis2_simple_http_svr_conn_t *svr_conn, 
+                                axis2_env_t **env, 
+                                const axis2_http_simple_response_t *response)
+{
+    AXIS2_FUNC_PARAM_CHECK(svr_conn, env, AXIS2_FAILURE);
+    /*
+        TODO stream dependant code
+    */
+    return AXIS2_SUCCESS;
+}



Mime
View raw message