You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by se...@apache.org on 2008/03/18 09:29:17 UTC
svn commit: r638262 - in /webservices/axis2/trunk/c:
include/axis2_http_transport.h include/axis2_msg_ctx.h
src/core/context/msg_ctx.c src/core/transport/http/common/http_worker.c
src/core/util/core_utils.c
Author: senaka
Date: Tue Mar 18 01:29:15 2008
New Revision: 638262
URL: http://svn.apache.org/viewvc?rev=638262&view=rev
Log:
Fixing JIRA Issue AXIS2C-1060
Modified:
webservices/axis2/trunk/c/include/axis2_http_transport.h
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/util/core_utils.c
Modified: webservices/axis2/trunk/c/include/axis2_http_transport.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/include/axis2_http_transport.h?rev=638262&r1=638261&r2=638262&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_http_transport.h (original)
+++ webservices/axis2/trunk/c/include/axis2_http_transport.h Tue Mar 18 01:29:15 2008
@@ -282,6 +282,11 @@
*/
#define AXIS2_HTTP_HEADER_CONTENT_LENGTH "Content-Length"
+ /**
+ * HEADER_CONTENT_LANGUAGE
+ */
+#define AXIS2_HTTP_HEADER_CONTENT_LANGUAGE "Content-Language"
+
#define AXIS2_HTTP_HEADER_CONTENT_LENGTH_ "Content-Length: "
/**
@@ -520,6 +525,11 @@
* HEADER_ACCEPT_CHARSET
*/
#define AXIS2_HTTP_HEADER_ACCEPT_CHARSET "Accept-Charset"
+
+ /**
+ * AXIS2_HTTP_HEADER_ACCEPT_LANGUAGE
+ */
+#define AXIS2_HTTP_HEADER_ACCEPT_LANGUAGE "Accept-Language"
/**
* HEADER_ALLOW
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=638262&r1=638261&r2=638262&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_msg_ctx.h (original)
+++ webservices/axis2/trunk/c/include/axis2_msg_ctx.h Tue Mar 18 01:29:15 2008
@@ -1772,6 +1772,67 @@
axutil_array_list_t * accept_charset_record_list);
/**
+ * Retrieves HTTP Accept-Language records.
+ * @param msg_ctx message context
+ * @param env pointer to environment struct
+ * @return HTTP Accept-Language records associated.
+ */
+ AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+ axis2_msg_ctx_get_http_accept_language_record_list(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env);
+
+ /**
+ * Retrieves HTTP Accept-Language records, and removes them
+ * from the message context
+ * @param msg_ctx message context
+ * @param env pointer to environment struct
+ * @return HTTP Accept-Language records associated.
+ */
+ AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+ axis2_msg_ctx_extract_http_accept_language_record_list(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env);
+
+ /**
+ * Sets the HTTP Accept-Language records
+ * @param msg_ctx message context
+ * @param env pointer to environment struct
+ * @param accept_language_record_list an Array List containing the
+ * HTTP Accept-Language records
+ * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
+ */
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ axis2_msg_ctx_set_http_accept_language_record_list(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axutil_array_list_t * accept_language_record_list);
+
+ /**
+ * Gets the Content Language used
+ * @param msg_ctx message context
+ * @param env pointer to environment struct
+ * @return Content Language string
+ */
+ AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+ axis2_msg_ctx_get_content_language(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env);
+
+ /**
+ * Sets the Content Language used
+ * @param msg_ctx message context
+ * @param env pointer to environment struct
+ * @param str Content Language string
+ * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
+ */
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ axis2_msg_ctx_set_content_language(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axis2_char_t * str);
+
+ /**
* Retrieves HTTP Accept records.
* @param msg_ctx message context
* @param env pointer to environment struct
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=638262&r1=638261&r2=638262&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/context/msg_ctx.c (original)
+++ webservices/axis2/trunk/c/src/core/context/msg_ctx.c Tue Mar 18 01:29:15 2008
@@ -203,7 +203,9 @@
axutil_hash_t *transport_headers;
axutil_array_list_t *accept_record_list;
axutil_array_list_t *accept_charset_record_list;
+ axutil_array_list_t *accept_language_record_list;
axis2_char_t *transfer_encoding;
+ axis2_char_t *content_language;
axis2_char_t *transport_url;
axis2_bool_t is_auth_failure;
axis2_bool_t required_auth_is_http;
@@ -279,7 +281,9 @@
msg_ctx->transport_headers = NULL;
msg_ctx->accept_record_list = NULL;
msg_ctx->accept_charset_record_list = NULL;
+ msg_ctx->accept_language_record_list = NULL;
msg_ctx->transfer_encoding = NULL;
+ msg_ctx->content_language = NULL;
msg_ctx->transport_url = NULL;
msg_ctx->response_soap_envelope = NULL;
msg_ctx->is_auth_failure = AXIS2_FALSE;
@@ -441,6 +445,21 @@
axutil_array_list_free(msg_ctx->accept_charset_record_list, env);
}
+ if (msg_ctx->accept_language_record_list)
+ {
+ axis2_http_accept_record_t *rec = NULL;
+ while (axutil_array_list_size(msg_ctx->accept_language_record_list, env))
+ {
+ rec = (axis2_http_accept_record_t *)
+ axutil_array_list_remove(msg_ctx->accept_language_record_list, env, 0);
+ if (rec)
+ {
+ axis2_http_accept_record_free(rec, env);
+ }
+ }
+ axutil_array_list_free(msg_ctx->accept_language_record_list, env);
+ }
+
if (msg_ctx->accept_record_list)
{
axis2_http_accept_record_t *rec = NULL;
@@ -461,6 +480,11 @@
AXIS2_FREE(env->allocator, msg_ctx->transfer_encoding);
}
+ if (msg_ctx->content_language)
+ {
+ AXIS2_FREE(env->allocator, msg_ctx->content_language);
+ }
+
if (msg_ctx->auth_type)
{
AXIS2_FREE(env->allocator, msg_ctx->auth_type);
@@ -2356,6 +2380,72 @@
return AXIS2_SUCCESS;
}
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_msg_ctx_get_http_accept_language_record_list(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ if (msg_ctx)
+ {
+ return msg_ctx->accept_language_record_list;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_msg_ctx_extract_http_accept_language_record_list(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ axutil_array_list_t *temp = NULL;
+ if (msg_ctx)
+ {
+ temp = msg_ctx->accept_language_record_list;
+ msg_ctx->accept_language_record_list = NULL;
+ return temp;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_http_accept_language_record_list(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axutil_array_list_t * accept_language_record_list)
+{
+ if (msg_ctx)
+ {
+ if (msg_ctx->accept_language_record_list &&
+ msg_ctx->accept_language_record_list != accept_language_record_list)
+ {
+ axis2_http_accept_record_t *rec = NULL;
+ while (axutil_array_list_size(msg_ctx->accept_language_record_list, env))
+ {
+ rec = (axis2_http_accept_record_t *)
+ axutil_array_list_remove(msg_ctx->accept_language_record_list, env, 0);
+ if (rec)
+ {
+ axis2_http_accept_record_free(rec, env);
+ }
+ }
+ axutil_array_list_free(msg_ctx->accept_language_record_list, env);
+ }
+ msg_ctx->accept_language_record_list = accept_language_record_list;
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axis2_msg_ctx_get_transfer_encoding(
axis2_msg_ctx_t * msg_ctx,
@@ -2383,6 +2473,43 @@
if (str)
{
msg_ctx->transfer_encoding = str;
+ }
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+axis2_msg_ctx_get_content_language(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ if (msg_ctx)
+ return msg_ctx->content_language;
+ else
+ return NULL;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_content_language(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axis2_char_t * str)
+{
+ if (msg_ctx)
+ {
+ if (msg_ctx->content_language)
+ {
+ AXIS2_FREE(env->allocator, msg_ctx->content_language);
+ msg_ctx->content_language = NULL;
+ }
+ if (str)
+ {
+ msg_ctx->content_language = str;
}
}
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=638262&r1=638261&r2=638262&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 Tue Mar 18 01:29:15 2008
@@ -143,6 +143,8 @@
axis2_http_header_t *accept_header = NULL;
axis2_char_t *accept_charset_header_value = NULL;
axis2_http_header_t *accept_charset_header = NULL;
+ axis2_char_t *accept_language_header_value = NULL;
+ axis2_http_header_t *accept_language_header = NULL;
AXIS2_ENV_CHECK(env, AXIS2_FALSE);
AXIS2_PARAM_CHECK(env->error, svr_conn, AXIS2_FALSE);
@@ -378,6 +380,53 @@
}
}
+ accept_language_header = axis2_http_simple_request_get_first_header(
+ simple_request,
+ env,
+ AXIS2_HTTP_HEADER_ACCEPT_LANGUAGE);
+ if (accept_language_header)
+ {
+ accept_language_header_value = axis2_http_header_get_value(accept_language_header,
+ env);
+ }
+ if (accept_language_header_value)
+ {
+ axutil_array_list_t *accept_language_header_field_list = NULL;
+ axutil_array_list_t *accept_language_record_list = NULL;
+ accept_language_header_field_list =
+ axutil_tokenize(env, accept_language_header_value, ',');
+ if (accept_language_header_field_list &&
+ axutil_array_list_size(accept_language_header_field_list, env) > 0)
+ {
+ axis2_char_t *token = NULL;
+ accept_language_record_list =
+ axutil_array_list_create(env,
+ axutil_array_list_size(accept_language_header_field_list, env));
+ do
+ {
+ if (token)
+ {
+ axis2_http_accept_record_t *rec = NULL;
+ rec = axis2_http_accept_record_create(env, token);
+ if (rec)
+ {
+ axutil_array_list_add(accept_language_record_list, env, rec);
+ }
+ AXIS2_FREE(env->allocator, token);
+ }
+ token = (axis2_char_t *)
+ axutil_array_list_remove(accept_language_header_field_list, env, 0);
+ }
+ while(token);
+ }
+ if (accept_language_record_list &&
+ axutil_array_list_size(accept_language_record_list, env) > 0)
+ {
+ axis2_msg_ctx_set_http_accept_language_record_list(msg_ctx, env,
+ accept_language_record_list);
+ }
+ }
+
axis2_msg_ctx_set_transport_out_stream(msg_ctx, env, out_stream);
headers = axis2_http_worker_get_headers(http_worker, env, simple_request);
@@ -856,7 +905,29 @@
request_handled = AXIS2_TRUE;
status = AXIS2_TRUE;
}
+
op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+ if (op_ctx)
+ {
+ axis2_msg_ctx_t *out_msg_ctx = NULL;
+ axis2_msg_ctx_t **msg_ctx_map = NULL;
+ axis2_char_t *language_str = NULL;
+
+ msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env);
+ out_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_OUT];
+ if (out_msg_ctx)
+ {
+ language_str = axis2_msg_ctx_get_content_language(out_msg_ctx, env);
+ }
+ if (language_str && *language_str && !request_handled)
+ {
+ axis2_http_header_t *language = NULL;
+ language = axis2_http_header_create(env,
+ AXIS2_HTTP_HEADER_CONTENT_LANGUAGE,
+ language_str);
+ axis2_http_simple_response_set_header(response, env, language);
+ }
+ }
if (!request_handled)
{
axis2_bool_t do_rest = AXIS2_FALSE;
@@ -866,15 +937,22 @@
{
do_rest = AXIS2_TRUE;
}
- if ((accept_header_value || accept_charset_header_value) && do_rest)
+ if ((accept_header_value || accept_charset_header_value ||
+ accept_language_header_value) && do_rest)
{
axis2_char_t *content_type_header_value = NULL;
axis2_http_header_t *content_type_header = NULL;
axis2_char_t *temp = NULL;
+ axis2_char_t *language_header_value = NULL;
+ axis2_http_header_t *language_header = NULL;
content_type_header = axis2_http_simple_response_get_first_header(
response,
env,
AXIS2_HTTP_HEADER_CONTENT_TYPE);
+ language_header = axis2_http_simple_response_get_first_header(
+ response,
+ env,
+ AXIS2_HTTP_HEADER_CONTENT_LANGUAGE);
if (content_type_header)
{
content_type_header_value = axis2_http_header_get_value(content_type_header,
@@ -884,6 +962,11 @@
{
temp = axutil_strdup(env, content_type_header_value);
}
+ if (language_header)
+ {
+ language_header_value = axis2_http_header_get_value(language_header,
+ env);
+ }
if (temp)
{
axis2_char_t *content_type = NULL;
@@ -1008,6 +1091,43 @@
if (char_set)
{
AXIS2_FREE(env->allocator, char_set);
+ }
+ }
+ if (language_header_value)
+ {
+ if (accept_language_header_value &&
+ !strstr(accept_language_header_value, language_header_value))
+ {
+ axis2_http_header_t *cont_len = NULL;
+ axis2_http_header_t *cont_type = NULL;
+ axis2_char_t *body_string = NULL;
+ axis2_http_simple_response_set_status_line(response, env, http_version,
+ AXIS2_HTTP_RESPONSE_NOT_ACCEPTABLE_CODE_VAL,
+ AXIS2_HTTP_RESPONSE_NOT_ACCEPTABLE_CODE_NAME);
+ body_string = axis2_http_transport_utils_get_not_acceptable(env,
+ conf_ctx);
+ cont_type = axis2_http_header_create(env,
+ AXIS2_HTTP_HEADER_CONTENT_TYPE,
+ AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML);
+ axis2_http_simple_response_set_header(response, env, cont_type);
+ axis2_http_simple_response_remove_headers(response, env, AXIS2_HTTP_HEADER_CONTENT_LANGUAGE);
+ if (body_string)
+ {
+ axis2_char_t str_len[10];
+ axis2_http_simple_response_set_body_string(response, env,
+ body_string);
+ sprintf(str_len, "%d", axutil_strlen(body_string));
+ cont_len = axis2_http_header_create(env,
+ AXIS2_HTTP_HEADER_CONTENT_LENGTH,
+ str_len);
+ axis2_http_simple_response_set_header(response, env, cont_len);
+ }
+ axis2_http_worker_set_response_headers(http_worker, env, svr_conn,
+ simple_request, response, 0);
+ axis2_simple_http_svr_conn_write_response(svr_conn, env, response);
+ request_handled = AXIS2_TRUE;
+ status = AXIS2_TRUE;
+ response_written = AXIS2_TRUE;
}
}
}
Modified: webservices/axis2/trunk/c/src/core/util/core_utils.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/util/core_utils.c?rev=638262&r1=638261&r2=638262&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/util/core_utils.c (original)
+++ webservices/axis2/trunk/c/src/core/util/core_utils.c Tue Mar 18 01:29:15 2008
@@ -93,6 +93,8 @@
axis2_msg_ctx_extract_http_accept_record_list(in_msg_ctx, env));
axis2_msg_ctx_set_http_accept_charset_record_list(new_msg_ctx, env,
axis2_msg_ctx_extract_http_accept_charset_record_list(in_msg_ctx, env));
+ axis2_msg_ctx_set_http_accept_language_record_list(new_msg_ctx, env,
+ axis2_msg_ctx_extract_http_accept_language_record_list(in_msg_ctx, env));
old_msg_info_headers = axis2_msg_ctx_get_msg_info_headers(in_msg_ctx, env);
if (!old_msg_info_headers)
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org