You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2005/12/19 07:19:59 UTC
svn commit: r357654 -
/webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_out_transport_info.c
Author: samisa
Date: Sun Dec 18 22:19:52 2005
New Revision: 357654
URL: http://svn.apache.org/viewcvs?rev=357654&view=rev
Log:
Added http_out_transport_info
Added:
webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_out_transport_info.c
Added: webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_out_transport_info.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_out_transport_info.c?rev=357654&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_out_transport_info.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/src/axis2_http_out_transport_info.c Sun Dec 18 22:19:52 2005
@@ -0,0 +1,171 @@
+/*
+ * 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, 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, NULL);
+ 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;
+}