Hi, I've been also working on some enhancements for axis in order to support some required features to our project. We are using axis2/c module for apache instead of the standalone server, changes are not tested for the standalone.
#1 Adds http headers to msg_ctx when using axis2/c module for apache I noticed however this functionality were only implemented for the standalone server. When using the axis module for apache http headers were not added to the msg_ctx so they were not accessible @ the inflow handlers level for instance. #2 Adds forbidden definition tags for http forbidden code which is missing in standard release #define AXIS2_HTTP_RESPONSE_FORBIDDEN_CODE_VAL 403 #define AXIS2_HTTP_RESPONSE_HTTP_FORBIDDEN_CODE_NAME "Forbidden" #define AXIS2_HTTP_RESPONSE_HTTP_FORBIDDEN "403 Forbidden" #3 Adds support to specify feedback for REST requests, when a module failure occurs. This issue is related to the difference between soap and rest requests. When an inflow handler fails two things can happen depending on the request type: - For SOAP requests, the inflow handler chain is broken, and all the outflow fault handlers are invoked. The response soap envelope response containing a default fault is built by axis in between these phases, so we can edit the fault accordingly @ the outflow fault handlers. - For REST requests, the inflow handler chain is also broken, but the outflow fault handlers are not invoked. This is not a problem, and is probably intended, since unlike soap there is no need to create a soap envelope. The thing is when this happens it always returned 202 ACCEPTED, which is not enough to provide any feedback to the user who made the request. @ the inflow handler is now possible to set the desired status code desired for the response, extra http headers, and/or http content. It was already possible before, changes just weren't propagated to the actual response. inflow handler example with the patch: .. // For REST requests if (doing_rest && AXIS2_FAILURE == result) { axis2_msg_ctx_set_status_code(msg_ctx, env, AXIS2_HTTP_RESPONSE_HTTP_UNAUTHORIZED_CODE_VAL); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[Inflow][authentication_in] HTTP status code unauthorized"); axutil_stream_t *stream = axutil_stream_create_basic(env); axis2_char_t *http_content = axutil_strcat(env, AXIS2_HTTP_RESPONSE_HTTP_UNAUTHORIZED, "\n", NULL); axutil_stream_write(stream, env, http_content, axutil_strlen(http_content)); axis2_msg_ctx_set_transport_out_stream(msg_ctx, env, stream); } return result; } I think these features may also be of interest for axis2/c users, at least for us they seemed important, and would be nice to to have to patch these to each new release of axis. The diff's follow in attachment. Regards, Luís Bilo
diff -r -u --exclude='*Makefile*' --exclude='*.o' --exclude='*.la' --exclude=axis2_http_server --exclude='*.Plo' --exclude='*.a' --exclude='*.lo' --exclude='*.lai' --exclude='*.so*' --exclude='*.loT' --exclude='*.Tpo' /home/luis/packages/axis2c1.5.clean/include/axis2_http_transport.h /home/luis/packages/axis2c-src-1.5.0/include/axis2_http_transport.h --- /home/luis/packages/axis2c1.5.clean/include/axis2_http_transport.h 2008-07-10 13:53:40.000000000 +0100 +++ /home/luis/packages/axis2c-src-1.5.0/include/axis2_http_transport.h 2008-10-24 13:26:15.000000000 +0100 @@ -141,6 +141,11 @@ #define AXIS2_HTTP_RESPONSE_HTTP_UNAUTHORIZED_CODE_VAL 401 /** + * RESPONSE_HTTP_FORBIDDEN_CODE_VAL + */ +#define AXIS2_HTTP_RESPONSE_FORBIDDEN_CODE_VAL 403 + + /** * RESPONSE_NOT_FOUND_CODE_VAL */ #define AXIS2_HTTP_RESPONSE_NOT_FOUND_CODE_VAL 404 @@ -276,6 +281,11 @@ #define AXIS2_HTTP_RESPONSE_HTTP_UNAUTHORIZED_CODE_NAME "Unauthorized" /** + * RESPONSE_HTTP_FORBIDDEN_CODE_NAME + */ +#define AXIS2_HTTP_RESPONSE_HTTP_FORBIDDEN_CODE_NAME "Forbidden" + + /** * RESPONSE_NOT_FOUND_CODE_NAME */ #define AXIS2_HTTP_RESPONSE_NOT_FOUND_CODE_NAME "Not Found" @@ -773,6 +783,11 @@ #define AXIS2_HTTP_RESPONSE_HTTP_UNAUTHORIZED "401 Unauthorized" /** + * RESPONSE_HTTP_FORBIDDEN + */ +#define AXIS2_HTTP_RESPONSE_HTTP_FORBIDDEN "403 Forbidden" + + /** * RESPONSE_PROXY_AUTHENTICATION_REQUIRED */ #define AXIS2_HTTP_RESPONSE_PROXY_AUTHENTICATION_REQUIRED "407 Proxy Authentication Required"
--- /home/luis/packages/axis2c1.5.clean/src/core/transport/http/server/apache2/apache2_worker.c 2008-07-10 13:52:28.000000000 +0100 +++ /home/luis/packages/axis2c-src-1.5.0/src/core/transport/http/server/apache2/apache2_worker.c 2008-10-27 12:28:25.000000000 +0000 @@ -42,6 +42,11 @@ axis2_conf_ctx_t *conf_ctx; }; +axutil_hash_t * +axis2_apache2_worker_get_headers( + const axutil_env_t * env, + request_rec * request); + AXIS2_EXTERN axis2_apache2_worker_t *AXIS2_CALL axis2_apache2_worker_create( const axutil_env_t * env, @@ -173,6 +178,7 @@ axis2_char_t *accept_charset_header_value = NULL; axis2_char_t *accept_language_header_value = NULL; axis2_char_t *content_language_header_value = NULL; + axutil_hash_t *headers = NULL; AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE); AXIS2_PARAM_CHECK(env->error, request, AXIS2_CRITICAL_FAILURE); @@ -386,6 +392,9 @@ } } + headers = axis2_apache2_worker_get_headers(env, request); + axis2_msg_ctx_set_transport_headers(msg_ctx, env, headers); + soap_action_header_txt = (axis2_char_t *) apr_table_get(request->headers_in,AXIS2_HTTP_HEADER_SOAP_ACTION); if(soap_action_header_txt){ @@ -1130,8 +1139,95 @@ } if (send_status == DECLINED) { - request->status = HTTP_ACCEPTED; - send_status = DONE; + if (msg_ctx) + { + int size = 0; + axutil_array_list_t *output_header_list = NULL; + output_header_list = axis2_msg_ctx_get_http_output_headers(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)); + } + + int status_code = axis2_msg_ctx_get_status_code(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_MULTIPLE_CHOICES_CODE_VAL: + request->status = HTTP_MULTIPLE_CHOICES; + break; + case AXIS2_HTTP_RESPONSE_MOVED_PERMANENTLY_CODE_VAL: + request->status = HTTP_MOVED_PERMANENTLY; + break; + case AXIS2_HTTP_RESPONSE_SEE_OTHER_CODE_VAL: + request->status = HTTP_SEE_OTHER; + break; + case AXIS2_HTTP_RESPONSE_NOT_MODIFIED_CODE_VAL: + request->status = HTTP_NOT_MODIFIED; + break; + case AXIS2_HTTP_RESPONSE_TEMPORARY_REDIRECT_CODE_VAL: + request->status = HTTP_TEMPORARY_REDIRECT; + break; + case AXIS2_HTTP_RESPONSE_BAD_REQUEST_CODE_VAL: + request->status = HTTP_BAD_REQUEST; + break; + case AXIS2_HTTP_RESPONSE_REQUEST_TIMEOUT_CODE_VAL: + request->status = HTTP_REQUEST_TIME_OUT; + break; + case AXIS2_HTTP_RESPONSE_CONFLICT_CODE_VAL: + request->status = HTTP_CONFLICT; + break; + case AXIS2_HTTP_RESPONSE_GONE_CODE_VAL: + request->status = HTTP_GONE; + break; + case AXIS2_HTTP_RESPONSE_PRECONDITION_FAILED_CODE_VAL: + request->status = HTTP_PRECONDITION_FAILED; + break; + case AXIS2_HTTP_RESPONSE_REQUEST_ENTITY_TOO_LARGE_CODE_VAL: + request->status = HTTP_REQUEST_ENTITY_TOO_LARGE; + break; + case AXIS2_HTTP_RESPONSE_SERVICE_UNAVAILABLE_CODE_VAL: + request->status = HTTP_SERVICE_UNAVAILABLE; + break; + case AXIS2_HTTP_RESPONSE_FORBIDDEN_CODE_VAL: + request->status = HTTP_FORBIDDEN; + break; + case AXIS2_HTTP_RESPONSE_HTTP_UNAUTHORIZED_CODE_VAL: + request->status = HTTP_UNAUTHORIZED; + break; + default: + request->status = HTTP_ACCEPTED; + break; + } + + out_stream = axis2_msg_ctx_get_transport_out_stream(msg_ctx, env); + if (out_stream) + { + body_string = axutil_stream_get_buffer(out_stream, env); + body_string_len = axutil_stream_get_len(out_stream, env); + } + send_status = DONE; + } + else + { + request->status = HTTP_ACCEPTED; + send_status = DONE; + } } } else @@ -1252,3 +1348,29 @@ axutil_stream_free(tmp_stream, env); return buffer; } + +axutil_hash_t * +axis2_apache2_worker_get_headers( + const axutil_env_t * env, + request_rec * request) +{ + int i = 0; + axutil_hash_t *header_map = NULL; + header_map = axutil_hash_make(env); + + const apr_array_header_t *tarr = apr_table_elts(request->headers_in); + const apr_table_entry_t *telts = (const apr_table_entry_t*)tarr->elts; + + + axis2_http_header_t * tmp_http_header = NULL; + + for (i = 0; i < tarr->nelts; i++) + { + axis2_char_t* tmp_key = (axis2_char_t*) telts[i].key; + axis2_char_t* tmp_value = (axis2_char_t*) telts[i].val; + tmp_http_header = axis2_http_header_create(env, tmp_key, tmp_value); + axutil_hash_set(header_map, tmp_key, -1, tmp_http_header); + } + + return header_map; +}
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]