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/16 22:21:53 UTC

svn commit: r637663 - in /webservices/axis2/trunk/c/src/core/transport/http: common/http_worker.c server/apache2/apache2_worker.c

Author: senaka
Date: Sun Mar 16 14:21:50 2008
New Revision: 637663

URL: http://svn.apache.org/viewvc?rev=637663&view=rev
Log:
Fixing JIRA Issue AXIS2C-1059

Modified:
    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/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=637663&r1=637662&r2=637663&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 Sun Mar 16 14:21:50 2008
@@ -907,84 +907,87 @@
                 }
             }
         }
-        if (op_ctx && axis2_op_ctx_get_response_written(op_ctx, env))
+        if (!response_written)
         {
-            if (do_rest)
+            if (op_ctx && axis2_op_ctx_get_response_written(op_ctx, env))
             {
-                axis2_msg_ctx_t *out_msg_ctx = NULL;
-                axis2_msg_ctx_t *in_msg_ctx = NULL;
-                axis2_msg_ctx_t **msg_ctx_map = 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];
-                in_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN];
-                if (in_msg_ctx)
+                if (do_rest)
                 {
-                    /* TODO: Add neccessary handling */
+                    axis2_msg_ctx_t *out_msg_ctx = NULL;
+                    axis2_msg_ctx_t *in_msg_ctx = NULL;
+                    axis2_msg_ctx_t **msg_ctx_map = 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];
+                    in_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN];
+                    if (in_msg_ctx)
+                    {
+                        /* TODO: Add neccessary handling */
+                    }
+                    if (out_msg_ctx)
+                    {
+                        /* TODO: Add neccessary handling */
+                    }
                 }
-                if (out_msg_ctx)
+                if (!request_handled)
                 {
-                    /* TODO: Add neccessary handling */
+                    axis2_http_simple_response_set_status_line(response, env, http_version,
+                                                               AXIS2_HTTP_RESPONSE_OK_CODE_VAL,
+                                                               AXIS2_HTTP_RESPONSE_OK_CODE_NAME);
+                    if (!is_head)
+                    {
+                        axis2_http_simple_response_set_body_stream(response, env, out_stream);
+                    }
                 }
             }
-            if (!request_handled)
+            else if (op_ctx)
             {
-                axis2_http_simple_response_set_status_line(response, env, http_version,
-                                                           AXIS2_HTTP_RESPONSE_OK_CODE_VAL,
-                                                           AXIS2_HTTP_RESPONSE_OK_CODE_NAME);
-                if (!is_head)
+                if (do_rest)
                 {
-                    axis2_http_simple_response_set_body_stream(response, env, out_stream);
-                }
-            }
-        }
-        else if (op_ctx)
-        {
-            if (do_rest)
-            {
-                axis2_msg_ctx_t *out_msg_ctx = NULL;
-                axis2_msg_ctx_t *in_msg_ctx = NULL;
-                axis2_msg_ctx_t **msg_ctx_map = NULL;
+                    axis2_msg_ctx_t *out_msg_ctx = NULL;
+                    axis2_msg_ctx_t *in_msg_ctx = NULL;
+                    axis2_msg_ctx_t **msg_ctx_map = 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];
-                in_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN];
-                if (in_msg_ctx)
-                {
-                    /* TODO: Add neccessary handling */
-                }
-                if (out_msg_ctx)
-                {
-                    if (axis2_msg_ctx_get_no_content(out_msg_ctx, env))
+                    msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env);
+                    out_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_OUT];
+                    in_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN];
+                    if (in_msg_ctx)
                     {
-                        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;
+                        /* TODO: Add neccessary handling */
                     }
+                    if (out_msg_ctx)
+                    {
+                        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;
+                        }
+                    }
+                }
+                if (!request_handled)
+                {
+                    axis2_http_simple_response_set_status_line(response, env, http_version,
+                                                               AXIS2_HTTP_RESPONSE_ACK_CODE_VAL,
+                                                               AXIS2_HTTP_RESPONSE_ACK_CODE_NAME);
                 }
             }
-            if (!request_handled)
+            else
             {
                 axis2_http_simple_response_set_status_line(response, env, http_version,
                                                            AXIS2_HTTP_RESPONSE_ACK_CODE_VAL,
                                                            AXIS2_HTTP_RESPONSE_ACK_CODE_NAME);
             }
-        }
-        else if (!response_written)
-        {
-            axis2_http_simple_response_set_status_line(response, env, http_version,
-                                                       AXIS2_HTTP_RESPONSE_ACK_CODE_VAL,
-                                                       AXIS2_HTTP_RESPONSE_ACK_CODE_NAME);
-        }
-        if (!response_written)
-        {
-            axis2_http_worker_set_response_headers(http_worker, env, svr_conn,
-                                                   simple_request, response,
-                                                   axutil_stream_get_len(out_stream,
-                                                                         env));
-
-            status = axis2_simple_http_svr_conn_write_response(svr_conn, env, response);
+            if (!response_written)
+            {
+                axis2_http_worker_set_response_headers(http_worker, env, svr_conn,
+                                                       simple_request, response,
+                                                       axutil_stream_get_len(out_stream,
+                                                                             env));
+    
+                status = axis2_simple_http_svr_conn_write_response(svr_conn, env, response);
+            }
         }
     }
     if (url_external_form)

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=637663&r1=637662&r2=637663&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 Sun Mar 16 14:21:50 2008
@@ -401,7 +401,7 @@
                         }
                     }
                     *temp = '\0';
-                    apr_table_set(request->err_headers_out, "Allow", method_list_str);
+                    apr_table_set(request->err_headers_out, AXIS2_HTTP_HEADER_ALLOW, method_list_str);
                     AXIS2_FREE(env->allocator, method_list_str);
                     body_string =
                         axis2_http_transport_utils_get_method_not_allowed(env, conf_ctx);
@@ -503,7 +503,7 @@
                         }
                     }
                     *temp = '\0';
-                    apr_table_set(request->err_headers_out, "Allow", method_list_str);
+                    apr_table_set(request->err_headers_out, AXIS2_HTTP_HEADER_ALLOW, method_list_str);
                     AXIS2_FREE(env->allocator, method_list_str);
                     body_string =
                         axis2_http_transport_utils_get_method_not_allowed(env, conf_ctx);
@@ -587,6 +587,118 @@
 
     op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
 
+    if (send_status == DECLINED)
+    {
+        axis2_bool_t do_rest = AXIS2_FALSE;
+        axis2_char_t *accept_header_value = NULL;
+        axis2_char_t *accept_charset_header_value = NULL;
+        if (M_POST != request->method_number ||
+            axis2_msg_ctx_get_doing_rest(msg_ctx, env))
+        {
+            do_rest = AXIS2_TRUE;
+        }
+        accept_header_value = (axis2_char_t *)
+            apr_table_get(request->headers_in, AXIS2_HTTP_HEADER_ACCEPT);
+        accept_charset_header_value = (axis2_char_t *)
+            apr_table_get(request->headers_in, AXIS2_HTTP_HEADER_ACCEPT_CHARSET);
+        if ((accept_header_value || accept_charset_header_value) && do_rest)
+        {
+            axis2_char_t *content_type_header_value = NULL;
+            axis2_char_t *temp = NULL;
+            content_type_header_value = (axis2_char_t *) request->content_type;
+            if (content_type_header_value)
+            {
+                temp = axutil_strdup(env, content_type_header_value);
+            }
+            if (temp)
+            {
+                axis2_char_t *content_type = NULL;
+                axis2_char_t *char_set = NULL;
+                axis2_char_t *temp2 = NULL;
+                
+                temp2 = strchr(temp, ';');
+                if (temp2)
+                {
+                    *temp2 = '\0';
+                    temp2++;
+                    char_set = strstr(temp2, AXIS2_HTTP_CHAR_SET_ENCODING);
+                }
+                if (char_set)
+                {
+                    char_set = axutil_strltrim(env, char_set, " \t=");
+                }
+                if (char_set)
+                {
+                    temp2 = strchr(char_set, ';');
+                }
+                if (temp2)
+                {
+                    *temp2 = '\0';
+                }
+                content_type = axutil_strtrim(env, temp, NULL);
+
+                if (temp)
+                {
+                    AXIS2_FREE(env->allocator, temp);
+                    temp = NULL;
+                }
+                if (content_type && accept_header_value &&
+                    !strstr(accept_header_value, content_type))
+                {
+                    temp2 = strchr(content_type, '/');
+                    if (temp2)
+                    {
+                        *temp2 = '\0';
+                        temp = AXIS2_MALLOC(env->allocator,
+                                   sizeof(axis2_char_t) * ((int)strlen(content_type) + 3));
+                        if (!temp)
+                        {
+                            AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+                            return AXIS2_FALSE;
+                        }
+                        sprintf(temp, "%s/*", content_type);
+                        if (!strstr(accept_header_value, temp) &&
+                            !strstr(accept_header_value, AXIS2_HTTP_HEADER_ACCEPT_ALL))
+                        {
+                            body_string =
+                                axis2_http_transport_utils_get_not_acceptable(env, conf_ctx);
+                            request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
+
+                            if (body_string)
+                            {
+                                body_string_len = axutil_strlen(body_string);
+                            }
+                            send_status = OK;
+                            request->status = HTTP_NOT_ACCEPTABLE;
+                        }
+                        AXIS2_FREE(env->allocator, temp);
+                    }
+                }
+                if (content_type)
+                {
+                    AXIS2_FREE(env->allocator, content_type);
+                }
+                if (char_set && accept_charset_header_value && 
+                    !strstr(accept_charset_header_value, char_set))
+                {
+                    body_string =
+                        axis2_http_transport_utils_get_not_acceptable(env, conf_ctx);
+                    request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
+
+                    if (body_string)
+                    {
+                        body_string_len = axutil_strlen(body_string);
+                    }
+                    send_status = OK;
+                    request->status = HTTP_NOT_ACCEPTABLE;
+                }
+                if (char_set)
+                {
+                    AXIS2_FREE(env->allocator, char_set);
+                }
+            }
+        }
+    }
     if (send_status == DECLINED)
     {
         axis2_bool_t do_rest = AXIS2_FALSE;



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org