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/15 11:51:30 UTC
svn commit: r637390 - in /webservices/axis2/trunk/c/src/core/transport/http:
common/http_worker.c common/simple_http_svr_conn.c
util/http_transport_utils.c
Author: senaka
Date: Sat Mar 15 03:51:26 2008
New Revision: 637390
URL: http://svn.apache.org/viewvc?rev=637390&view=rev
Log:
Fixing JIRA Issue AXIS2C-1054
Modified:
webservices/axis2/trunk/c/src/core/transport/http/common/http_worker.c
webservices/axis2/trunk/c/src/core/transport/http/common/simple_http_svr_conn.c
webservices/axis2/trunk/c/src/core/transport/http/util/http_transport_utils.c
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=637390&r1=637389&r2=637390&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 Sat Mar 15 03:51:26 2008
@@ -384,13 +384,54 @@
}
else if (env->error->error_number == AXIS2_ERROR_SVC_OR_OP_NOT_FOUND)
{
- axis2_http_simple_response_set_status_line(response, env,
- http_version,
- 404,
- "Not Found");
+ axutil_array_list_t *method_list = NULL;
+ int size = 0;
+ method_list = axis2_msg_ctx_get_supported_rest_http_methods(msg_ctx, env);
+ size = axutil_array_list_size(method_list, env);
+ if (method_list && size)
+ {
+ axis2_http_header_t *allow_header = NULL;
+ axis2_char_t *method_list_str = NULL;
+ axis2_char_t *temp;
+ int i = 0;
+ method_list_str = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * 29);
+ temp = method_list_str;
+ for (i = 0; i < size; i++)
+ {
+ if (i)
+ {
+ sprintf(temp, ", ");
+ temp += 2;
+ }
+ sprintf(temp, "%s", (axis2_char_t *)
+ axutil_array_list_get(method_list, env, i));
+ temp += strlen(temp);
+ }
+ *temp = '\0';
+ axis2_http_simple_response_set_status_line(response, env,
+ http_version,
+ 405,
+ "Method Not Allowed");
+
+ body_string =
+ axis2_http_transport_utils_get_method_not_allowed(env,
+ conf_ctx);
+ allow_header = axis2_http_header_create(env,
+ "Allow",
+ method_list_str);
+ axis2_http_simple_response_set_header(response, env, allow_header);
+ AXIS2_FREE(env->allocator, method_list_str);
+ }
+ else
+ {
+ axis2_http_simple_response_set_status_line(response, env,
+ http_version,
+ 404,
+ "Not Found");
- body_string = axis2_http_transport_utils_get_not_found(env,
- conf_ctx);
+ body_string = axis2_http_transport_utils_get_not_found(env,
+ conf_ctx);
+ }
cont_type = axis2_http_header_create(env,
AXIS2_HTTP_HEADER_CONTENT_TYPE,
AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML);
@@ -459,13 +500,54 @@
axis2_char_t *body_string = NULL;
if (env->error->error_number == AXIS2_ERROR_SVC_OR_OP_NOT_FOUND)
{
- axis2_http_simple_response_set_status_line(response, env,
- http_version,
- 404,
- "Not Found");
+ axutil_array_list_t *method_list = NULL;
+ int size = 0;
+ method_list = axis2_msg_ctx_get_supported_rest_http_methods(msg_ctx, env);
+ size = axutil_array_list_size(method_list, env);
+ if (method_list && size)
+ {
+ axis2_http_header_t *allow_header = NULL;
+ axis2_char_t *method_list_str = NULL;
+ axis2_char_t *temp;
+ int i = 0;
+ method_list_str = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * 29);
+ temp = method_list_str;
+ for (i = 0; i < size; i++)
+ {
+ if (i)
+ {
+ sprintf(temp, ", ");
+ temp += 2;
+ }
+ sprintf(temp, "%s", (axis2_char_t *)
+ axutil_array_list_get(method_list, env, i));
+ temp += strlen(temp);
+ }
+ *temp = '\0';
+ axis2_http_simple_response_set_status_line(response, env,
+ http_version,
+ 405,
+ "Method Not Allowed");
+
+ body_string =
+ axis2_http_transport_utils_get_method_not_allowed(env,
+ conf_ctx);
+ allow_header = axis2_http_header_create(env,
+ "Allow",
+ method_list_str);
+ axis2_http_simple_response_set_header(response, env, allow_header);
+ AXIS2_FREE(env->allocator, method_list_str);
+ }
+ else
+ {
+ axis2_http_simple_response_set_status_line(response, env,
+ http_version,
+ 404,
+ "Not Found");
- body_string = axis2_http_transport_utils_get_not_found(env,
- conf_ctx);
+ body_string = axis2_http_transport_utils_get_not_found(env,
+ conf_ctx);
+ }
cont_type = axis2_http_header_create(env,
AXIS2_HTTP_HEADER_CONTENT_TYPE,
AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML);
Modified: webservices/axis2/trunk/c/src/core/transport/http/common/simple_http_svr_conn.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/common/simple_http_svr_conn.c?rev=637390&r1=637389&r2=637390&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/common/simple_http_svr_conn.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/common/simple_http_svr_conn.c Sat Mar 15 03:51:26 2008
@@ -82,10 +82,7 @@
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- if (svr_conn->stream)
- {
axutil_stream_free(svr_conn->stream, env);
- }
if (-1 != svr_conn->socket)
{
axutil_network_handler_close_socket(env, svr_conn->socket);
Modified: webservices/axis2/trunk/c/src/core/transport/http/util/http_transport_utils.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/util/http_transport_utils.c?rev=637390&r1=637389&r2=637390&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/util/http_transport_utils.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/util/http_transport_utils.c Sat Mar 15 03:51:26 2008
@@ -1344,6 +1344,17 @@
}
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+axis2_http_transport_utils_get_method_not_allowed(
+ const axutil_env_t * env,
+ axis2_conf_ctx_t * conf_ctx)
+{
+ return "<html><head><title>405 Method Not Allowed</title></head>"
+ "<body><h2>Method Not Allowed</h2><p>The requested method is not"
+ " allowed for this URL.</p></body></html>";
+}
+
+
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axis2_http_transport_utils_get_services_html(
const axutil_env_t * env,
axis2_conf_ctx_t * conf_ctx)
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org