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 se...@apache.org on 2008/03/19 09:05:43 UTC
svn commit: r638739 - in /webservices/axis2/trunk/c: include/axis2_msg_ctx.h
src/core/context/msg_ctx.c src/core/transport/http/common/http_worker.c
src/core/transport/http/server/apache2/apache2_worker.c
Author: senaka
Date: Wed Mar 19 01:05:41 2008
New Revision: 638739
URL: http://svn.apache.org/viewvc?rev=638739&view=rev
Log:
Adding ability to specify custom headers and status code at server side
Modified:
webservices/axis2/trunk/c/include/axis2_msg_ctx.h
webservices/axis2/trunk/c/src/core/context/msg_ctx.c
webservices/axis2/trunk/c/src/core/transport/http/common/http_worker.c
webservices/axis2/trunk/c/src/core/transport/http/server/apache2/apache2_worker.c
Modified: webservices/axis2/trunk/c/include/axis2_msg_ctx.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/include/axis2_msg_ctx.h?rev=638739&r1=638738&r2=638739&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_msg_ctx.h (original)
+++ webservices/axis2/trunk/c/include/axis2_msg_ctx.h Wed Mar 19 01:05:41 2008
@@ -2024,6 +2024,30 @@
axis2_msg_ctx_t * msg_ctx,
const axutil_env_t * env);
+ /**
+ * Sets the Output Header list
+ * @param msg_ctx message context
+ * @param env pointer to environment struct
+ * @param output_headers Output Header list
+ * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
+ */
+ AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+ axis2_msg_ctx_get_http_output_headers(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env);
+
+ /**
+ * Gets the Output Header list
+ * @param msg_ctx message context
+ * @param env pointer to environment struct
+ * @return Output Header list
+ */
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ axis2_msg_ctx_set_http_output_headers(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axutil_array_list_t * output_headers);
+
/** @} */
#ifdef __cplusplus
Modified: webservices/axis2/trunk/c/src/core/context/msg_ctx.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/context/msg_ctx.c?rev=638739&r1=638738&r2=638739&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/context/msg_ctx.c (original)
+++ webservices/axis2/trunk/c/src/core/context/msg_ctx.c Wed Mar 19 01:05:41 2008
@@ -26,6 +26,7 @@
#include <axis2_transport_out_desc.h>
#include <axis2_http_out_transport_info.h>
#include <axis2_http_accept_record.h>
+#include <axis2_http_header.h>
#include <axiom_soap_envelope.h>
#include <axiom_soap_const.h>
#include <axis2_options.h>
@@ -130,8 +131,7 @@
axis2_bool_t manage_session;
/* http status code */
-
- unsigned int status_code;
+ int status_code;
/** use SOAP 1.1? */
axis2_bool_t is_soap_11;
@@ -201,6 +201,7 @@
axutil_stream_t *transport_out_stream;
axis2_http_out_transport_info_t *http_out_transport_info;
axutil_hash_t *transport_headers;
+ axutil_array_list_t *output_headers;
axutil_array_list_t *accept_record_list;
axutil_array_list_t *accept_charset_record_list;
axutil_array_list_t *accept_language_record_list;
@@ -281,6 +282,7 @@
msg_ctx->transport_headers = NULL;
msg_ctx->accept_record_list = NULL;
msg_ctx->accept_charset_record_list = NULL;
+ msg_ctx->output_headers = NULL;
msg_ctx->accept_language_record_list = NULL;
msg_ctx->transfer_encoding = NULL;
msg_ctx->content_language = NULL;
@@ -290,6 +292,7 @@
msg_ctx->required_auth_is_http = AXIS2_FALSE;
msg_ctx->auth_type = NULL;
msg_ctx->no_content = AXIS2_FALSE;
+ msg_ctx->status_code = 0;
msg_ctx->base = axis2_ctx_create(env);
if (!(msg_ctx->base))
@@ -445,6 +448,21 @@
axutil_array_list_free(msg_ctx->accept_charset_record_list, env);
}
+ if (msg_ctx->output_headers)
+ {
+ axis2_http_header_t *header = NULL;
+ while (axutil_array_list_size(msg_ctx->output_headers, env))
+ {
+ header = (axis2_http_header_t *)
+ axutil_array_list_remove(msg_ctx->output_headers, env, 0);
+ if (header)
+ {
+ axis2_http_header_free(header, env);
+ }
+ }
+ axutil_array_list_free(msg_ctx->output_headers, env);
+ }
+
if (msg_ctx->accept_language_record_list)
{
axis2_http_accept_record_t *rec = NULL;
@@ -2371,6 +2389,54 @@
axutil_array_list_free(msg_ctx->accept_charset_record_list, env);
}
msg_ctx->accept_charset_record_list = accept_charset_record_list;
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_msg_ctx_get_http_output_headers(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ if (msg_ctx)
+ {
+ return msg_ctx->output_headers;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_http_output_headers(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axutil_array_list_t * output_headers)
+{
+ if (msg_ctx)
+ {
+ if (msg_ctx->output_headers &&
+ msg_ctx->output_headers != output_headers)
+ {
+ axis2_http_header_t *header = NULL;
+ while (axutil_array_list_size(msg_ctx->output_headers, env))
+ {
+ header = (axis2_http_header_t *)
+ axutil_array_list_remove(msg_ctx->output_headers, env, 0);
+ if (header)
+ {
+ axis2_http_header_free(header, env);
+ }
+ }
+ axutil_array_list_free(msg_ctx->output_headers, env);
+ }
+ msg_ctx->output_headers = output_headers;
}
else
{
Modified: webservices/axis2/trunk/c/src/core/transport/http/common/http_worker.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/common/http_worker.c?rev=638739&r1=638738&r2=638739&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/common/http_worker.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/common/http_worker.c Wed Mar 19 01:05:41 2008
@@ -1150,7 +1150,40 @@
}
if (out_msg_ctx)
{
- /* TODO: Add neccessary handling */
+ int size = 0;
+ axutil_array_list_t *output_header_list = NULL;
+ output_header_list = axis2_msg_ctx_get_http_output_headers(out_msg_ctx, env);
+ if (output_header_list)
+ {
+ size = axutil_array_list_size(output_header_list, env);
+ }
+ while (size)
+ {
+ size--;
+ axis2_http_simple_response_set_header(response, env, (axis2_http_header_t *)
+ axutil_array_list_get(output_header_list, env, size));
+ }
+ if (axis2_msg_ctx_get_status_code(out_msg_ctx, env))
+ {
+ int status_code = axis2_msg_ctx_get_status_code(out_msg_ctx, env);
+ axis2_char_t *status_code_str = NULL;
+ switch (status_code)
+ {
+ case AXIS2_HTTP_RESPONSE_CONTINUE_CODE_VAL:
+ status_code_str = AXIS2_HTTP_RESPONSE_CONTINUE_CODE_NAME;
+ break;
+ case AXIS2_HTTP_RESPONSE_ACK_CODE_VAL:
+ status_code_str = AXIS2_HTTP_RESPONSE_ACK_CODE_NAME;
+ break;
+ case AXIS2_HTTP_RESPONSE_BAD_REQUEST_CODE_VAL:
+ status_code_str = AXIS2_HTTP_RESPONSE_BAD_REQUEST_CODE_NAME;
+ break;
+ }
+ axis2_http_simple_response_set_status_line(response, env, http_version,
+ status_code,
+ status_code_str);
+ request_handled = AXIS2_TRUE;
+ }
}
}
if (!request_handled)
@@ -1181,11 +1214,45 @@
}
if (out_msg_ctx)
{
+ int size = 0;
+ axutil_array_list_t *output_header_list = NULL;
+ output_header_list = axis2_msg_ctx_get_http_output_headers(out_msg_ctx, env);
+ if (output_header_list)
+ {
+ size = axutil_array_list_size(output_header_list, env);
+ }
+ while (size)
+ {
+ size--;
+ axis2_http_simple_response_set_header(response, env, (axis2_http_header_t *)
+ axutil_array_list_get(output_header_list, env, size));
+ }
if (axis2_msg_ctx_get_no_content(out_msg_ctx, env))
{
axis2_http_simple_response_set_status_line(response, env, http_version,
AXIS2_HTTP_RESPONSE_NO_CONTENT_CODE_VAL,
AXIS2_HTTP_RESPONSE_NO_CONTENT_CODE_NAME);
+ request_handled = AXIS2_TRUE;
+ }
+ else if (axis2_msg_ctx_get_status_code(out_msg_ctx, env))
+ {
+ int status_code = axis2_msg_ctx_get_status_code(out_msg_ctx, env);
+ axis2_char_t *status_code_str = NULL;
+ switch (status_code)
+ {
+ case AXIS2_HTTP_RESPONSE_CONTINUE_CODE_VAL:
+ status_code_str = AXIS2_HTTP_RESPONSE_CONTINUE_CODE_NAME;
+ break;
+ case AXIS2_HTTP_RESPONSE_OK_CODE_VAL:
+ status_code_str = AXIS2_HTTP_RESPONSE_OK_CODE_NAME;
+ break;
+ case AXIS2_HTTP_RESPONSE_BAD_REQUEST_CODE_VAL:
+ status_code_str = AXIS2_HTTP_RESPONSE_BAD_REQUEST_CODE_NAME;
+ break;
+ }
+ axis2_http_simple_response_set_status_line(response, env, http_version,
+ status_code,
+ status_code_str);
request_handled = AXIS2_TRUE;
}
}
Modified: webservices/axis2/trunk/c/src/core/transport/http/server/apache2/apache2_worker.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/server/apache2/apache2_worker.c?rev=638739&r1=638738&r2=638739&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/server/apache2/apache2_worker.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/server/apache2/apache2_worker.c Wed Mar 19 01:05:41 2008
@@ -877,7 +877,40 @@
}
if (out_msg_ctx)
{
- /* TODO: Add neccessary handling */
+ int size = 0;
+ axutil_array_list_t *output_header_list = NULL;
+ output_header_list = axis2_msg_ctx_get_http_output_headers(out_msg_ctx, env);
+ if (output_header_list)
+ {
+ size = axutil_array_list_size(output_header_list, env);
+ }
+ while (size)
+ {
+ axis2_http_header_t *output_header = NULL;
+ size--;
+ output_header = (axis2_http_header_t *)
+ axutil_array_list_get(output_header_list, env, size);
+ apr_table_set(request->err_headers_out,
+ axis2_http_header_get_name(output_header, env),
+ axis2_http_header_get_value(output_header, env));
+ }
+ if (axis2_msg_ctx_get_status_code(out_msg_ctx, env))
+ {
+ int status_code = axis2_msg_ctx_get_status_code(out_msg_ctx, env);
+ switch (status_code)
+ {
+ case AXIS2_HTTP_RESPONSE_CONTINUE_CODE_VAL:
+ request->status = HTTP_CONTINUE;
+ break;
+ case AXIS2_HTTP_RESPONSE_ACK_CODE_VAL:
+ request->status = HTTP_ACCEPTED;
+ break;
+ case AXIS2_HTTP_RESPONSE_BAD_REQUEST_CODE_VAL:
+ request->status = HTTP_BAD_REQUEST;
+ break;
+ }
+ send_status = DONE;
+ }
}
}
if (send_status == DECLINED)
@@ -907,9 +940,43 @@
}
if (out_msg_ctx)
{
+ int size = 0;
+ axutil_array_list_t *output_header_list = NULL;
+ output_header_list = axis2_msg_ctx_get_http_output_headers(out_msg_ctx, env);
+ if (output_header_list)
+ {
+ size = axutil_array_list_size(output_header_list, env);
+ }
+ while (size)
+ {
+ axis2_http_header_t *output_header = NULL;
+ size--;
+ output_header = (axis2_http_header_t *)
+ axutil_array_list_get(output_header_list, env, size);
+ apr_table_set(request->err_headers_out,
+ axis2_http_header_get_name(output_header, env),
+ axis2_http_header_get_value(output_header, env));
+ }
if (axis2_msg_ctx_get_no_content(out_msg_ctx, env))
{
request->status = HTTP_NO_CONTENT;
+ send_status = DONE;
+ }
+ else if (axis2_msg_ctx_get_status_code(out_msg_ctx, env))
+ {
+ int status_code = axis2_msg_ctx_get_status_code(out_msg_ctx, env);
+ switch (status_code)
+ {
+ case AXIS2_HTTP_RESPONSE_CONTINUE_CODE_VAL:
+ request->status = HTTP_CONTINUE;
+ break;
+ case AXIS2_HTTP_RESPONSE_OK_CODE_VAL:
+ request->status = HTTP_OK;
+ break;
+ case AXIS2_HTTP_RESPONSE_BAD_REQUEST_CODE_VAL:
+ request->status = HTTP_BAD_REQUEST;
+ break;
+ }
send_status = DONE;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org