axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sen...@apache.org
Subject svn commit: r637455 - in /webservices/axis2/trunk/c: include/axis2_http_transport.h src/core/transport/http/common/http_worker.c src/core/transport/http/server/apache2/apache2_worker.c
Date Sat, 15 Mar 2008 19:35:59 GMT
Author: senaka
Date: Sat Mar 15 12:35:56 2008
New Revision: 637455

URL: http://svn.apache.org/viewvc?rev=637455&view=rev
Log:
Ensuring use of Appropriate Constants and Fixing JIRA Issue AXIS2C-1054

Modified:
    webservices/axis2/trunk/c/include/axis2_http_transport.h
    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_http_transport.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/include/axis2_http_transport.h?rev=637455&r1=637454&r2=637455&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_http_transport.h (original)
+++ webservices/axis2/trunk/c/include/axis2_http_transport.h Sat Mar 15 12:35:56 2008
@@ -68,35 +68,95 @@
      */
 #define AXIS2_HTTP_RESPONSE_WORD "RESPONSE_WORD"
 
+    /*
+     * RESPONSE_CONTINUE_CODE_VAL
+     */
+#define AXIS2_HTTP_RESPONSE_CONTINUE_CODE_VAL 100
+
+    /*
+     * RESPONSE_OK_CODE_VAL
+     */
+#define AXIS2_HTTP_RESPONSE_OK_CODE_VAL 200
+
+    /**
+     * RESPONSE_ACK_CODE_VAL
+     */
+#define AXIS2_HTTP_RESPONSE_ACK_CODE_VAL 202
+
     /**
-     * AXIS2_HTTP_RESPONSE_HTTP_UNAUTHORIZED_CODE_VAL
+     * RESPONSE_HTTP_UNAUTHORIZED_CODE_VAL
      */
 #define AXIS2_HTTP_RESPONSE_HTTP_UNAUTHORIZED_CODE_VAL 401
 
     /**
-      * AXIS2_HTTP_RESPONSE_PROXY_AUTHENTICATION_REQUIRED_CODE_VAL
-      */
-#define AXIS2_HTTP_RESPONSE_PROXY_AUTHENTICATION_REQUIRED_CODE_VAL 407
+     * RESPONSE_NOT_FOUND_CODE_VAL
+     */
+#define AXIS2_HTTP_RESPONSE_NOT_FOUND_CODE_VAL 404
 
     /**
-     * RESPONSE_ACK_CODE_VAL
+     * RESPONSE_METHOD_NOT_ALLOWED_CODE_VAL
      */
-#define AXIS2_HTTP_RESPONSE_ACK_CODE_VAL 202
+#define AXIS2_HTTP_RESPONSE_METHOD_NOT_ALLOWED_CODE_VAL 405
 
-    /*
-     * RESPONSE_OK_CODE_VAL
+    /**
+     * RESPONSE_PROXY_AUTHENTICATION_REQUIRED_CODE_VAL
      */
-#define AXIS2_HTTP_RESPONSE_OK_CODE_VAL 200
+#define AXIS2_HTTP_RESPONSE_PROXY_AUTHENTICATION_REQUIRED_CODE_VAL 407
 
-    /*
-     * RESPONSE_CONTINUE_CODE_VAL
+    /**
+     * RESPONSE_LENGTH_REQUIRED_CODE_VAL
      */
-#define AXIS2_HTTP_RESPONSE_CONTINUE_CODE_VAL 100
+#define AXIS2_HTTP_RESPONSE_LENGTH_REQUIRED_CODE_VAL 411
 
-    /*
+    /**
      * RESPONSE_INTERNAL_SERVER_ERROR_CODE_VAL
      */
-#define  AXIS2_HTTP_RESPONSE_INTERNAL_SERVER_ERROR_CODE_VAL 500
+#define AXIS2_HTTP_RESPONSE_INTERNAL_SERVER_ERROR_CODE_VAL 500
+
+    /**
+     * RESPONSE_CONTINUE_CODE_NAME
+     */
+#define AXIS2_HTTP_RESPONSE_CONTINUE_CODE_NAME "Continue"
+
+    /**
+     * RESPONSE_OK_CODE_NAME
+     */
+#define AXIS2_HTTP_RESPONSE_OK_CODE_NAME "OK"
+
+    /**
+     * RESPONSE_ACK_CODE_NAME
+     */
+#define AXIS2_HTTP_RESPONSE_ACK_CODE_NAME "Accepted"
+
+    /**
+     * RESPONSE_HTTP_UNAUTHORIZED_CODE_NAME
+     */
+#define AXIS2_HTTP_RESPONSE_HTTP_UNAUTHORIZED_CODE_NAME "Unauthorized"
+
+    /**
+     * RESPONSE_NOT_FOUND_CODE_NAME
+     */
+#define AXIS2_HTTP_RESPONSE_NOT_FOUND_CODE_NAME "Not Found"
+
+    /**
+     * RESPONSE_METHOD_NOT_ALLOWED_CODE_NAME
+     */
+#define AXIS2_HTTP_RESPONSE_METHOD_NOT_ALLOWED_CODE_NAME "Method Not Allowed"
+
+    /**
+     * RESPONSE_PROXY_AUTHENTICATION_REQUIRED_CODE_NAME
+     */
+#define AXIS2_HTTP_RESPONSE_PROXY_AUTHENTICATION_REQUIRED_CODE_NAME "Proxy Authentication
Required"
+
+    /**
+     * RESPONSE_LENGTH_REQUIRED_CODE_NAME
+     */
+#define AXIS2_HTTP_RESPONSE_LENGTH_REQUIRED_CODE_NAME "Length Required"
+
+    /**
+     * RESPONSE_INTERNAL_SERVER_ERROR_CODE_NAME
+     */
+#define AXIS2_HTTP_RESPONSE_INTERNAL_SERVER_ERROR_CODE_NAME "Internal Server Error"
 
     /**
      * SOCKET
@@ -401,6 +461,11 @@
 #define AXIS2_HTTP_HEADER_ACCEPT "Accept"
 
     /**
+     * HEADER_ALLOW
+     */
+#define AXIS2_HTTP_HEADER_ALLOW "Allow"
+
+    /**
      * HEADER_ACCEPT_TEXT_ALL
      */
 #define AXIS2_HTTP_HEADER_ACCEPT_TEXT_ALL "text/*"
@@ -503,7 +568,7 @@
     /**
      * RESPONSE_HTTP_INTERNAL_SERVER_ERROR
      */
-#define AXIS2_HTTP_RESPONSE_INTERNAL_SERVER_ERROR "500 Internal server error"
+#define AXIS2_HTTP_RESPONSE_INTERNAL_SERVER_ERROR "500 Internal Server Error"
 
     /**
      * HTTP_REQ_TYPE

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=637455&r1=637454&r2=637455&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 12:35:56
2008
@@ -182,8 +182,9 @@
                                (simple_request, env), env), AXIS2_HTTP_PUT))
         {
             axis2_http_simple_response_set_status_line(response, env,
-                                                       http_version, 411,
-                                                       "Length Required");
+                                                       http_version,
+                                                       AXIS2_HTTP_RESPONSE_LENGTH_REQUIRED_CODE_VAL,
+                                                       AXIS2_HTTP_RESPONSE_LENGTH_REQUIRED_CODE_NAME);
             status =
                 axis2_simple_http_svr_conn_write_response(svr_conn, env,
                                                           response);
@@ -359,7 +360,7 @@
                 axis2_http_simple_response_set_status_line(response, env,
                                                            http_version,
                                                            AXIS2_HTTP_RESPONSE_OK_CODE_VAL,
-                                                           "OK");
+                                                           AXIS2_HTTP_RESPONSE_OK_CODE_NAME);
                 body_string = axis2_http_transport_utils_get_services_html(env,
                                                                            conf_ctx);
                 cont_type = axis2_http_header_create(env,
@@ -372,7 +373,7 @@
                 axis2_http_simple_response_set_status_line(response, env,
                                                            http_version,
                                                            AXIS2_HTTP_RESPONSE_OK_CODE_VAL,
-                                                           "OK");
+                                                           AXIS2_HTTP_RESPONSE_OK_CODE_NAME);
                 body_string =
                     axis2_http_transport_utils_get_services_static_wsdl(env,
                                                                         conf_ctx,
@@ -410,14 +411,14 @@
                     *temp = '\0';
                     axis2_http_simple_response_set_status_line(response, env,
                                                                http_version,
-                                                               405,
-                                                               "Method Not Allowed");
+                                                               AXIS2_HTTP_RESPONSE_METHOD_NOT_ALLOWED_CODE_VAL,
+                                                               AXIS2_HTTP_RESPONSE_METHOD_NOT_ALLOWED_CODE_NAME);
 
                     body_string =
                         axis2_http_transport_utils_get_method_not_allowed(env,
                                                                           conf_ctx);
                     allow_header = axis2_http_header_create(env,
-                                                            "Allow",
+                                                            AXIS2_HTTP_HEADER_ALLOW,
                                                             method_list_str);
                     axis2_http_simple_response_set_header(response, env, allow_header);
                     AXIS2_FREE(env->allocator, method_list_str);
@@ -426,8 +427,8 @@
                 {
                     axis2_http_simple_response_set_status_line(response, env,
                                                                http_version,
-                                                               404,
-                                                               "Not Found");
+                                                               AXIS2_HTTP_RESPONSE_NOT_FOUND_CODE_VAL,
+                                                               AXIS2_HTTP_RESPONSE_NOT_FOUND_CODE_NAME);
 
                     body_string = axis2_http_transport_utils_get_not_found(env,
                                                                            conf_ctx);
@@ -441,8 +442,8 @@
             {
                 axis2_http_simple_response_set_status_line(response, env,
                                                            http_version,
-                                                           500,
-                                                           "Internal Server Error");
+                                                           AXIS2_HTTP_RESPONSE_INTERNAL_SERVER_ERROR_CODE_VAL,
+                                                           AXIS2_HTTP_RESPONSE_INTERNAL_SERVER_ERROR_CODE_NAME);
 
                 body_string = axis2_http_transport_utils_get_services_html(env,
                                                                            conf_ctx);
@@ -526,14 +527,14 @@
                     *temp = '\0';
                     axis2_http_simple_response_set_status_line(response, env,
                                                                http_version,
-                                                               405,
-                                                               "Method Not Allowed");
+                                                               AXIS2_HTTP_RESPONSE_METHOD_NOT_ALLOWED_CODE_VAL,
+                                                               AXIS2_HTTP_RESPONSE_METHOD_NOT_ALLOWED_CODE_NAME);
 
                     body_string =
                         axis2_http_transport_utils_get_method_not_allowed(env,
                                                                           conf_ctx);
                     allow_header = axis2_http_header_create(env,
-                                                            "Allow",
+                                                            AXIS2_HTTP_HEADER_ALLOW,
                                                             method_list_str);
                     axis2_http_simple_response_set_header(response, env, allow_header);
                     AXIS2_FREE(env->allocator, method_list_str);
@@ -542,8 +543,8 @@
                 {
                     axis2_http_simple_response_set_status_line(response, env,
                                                                http_version,
-                                                               404,
-                                                               "Not Found");
+                                                               AXIS2_HTTP_RESPONSE_NOT_FOUND_CODE_VAL,
+                                                               AXIS2_HTTP_RESPONSE_NOT_FOUND_CODE_NAME);
 
                     body_string = axis2_http_transport_utils_get_not_found(env,
                                                                            conf_ctx);
@@ -557,8 +558,8 @@
             {
                 axis2_http_simple_response_set_status_line(response, env,
                                                            http_version,
-                                                           500,
-                                                           "Internal Server Error");
+                                                           AXIS2_HTTP_RESPONSE_INTERNAL_SERVER_ERROR_CODE_VAL,
+                                                           AXIS2_HTTP_RESPONSE_INTERNAL_SERVER_ERROR_CODE_NAME);
 
                 body_string = axis2_http_transport_utils_get_services_html(env,
                                                                            conf_ctx);
@@ -632,9 +633,9 @@
             {
                 if (!http_error_value)
                 {
-                    sprintf(status_line_str, "%s 500 Internal Server Error\r\n",
-                            axis2_http_request_line_get_http_version(req_line,
-                                                                     env));
+                    sprintf(status_line_str, "%s %s\r\n",
+                            axis2_http_request_line_get_http_version(req_line, env),
+                            AXIS2_HTTP_RESPONSE_INTERNAL_SERVER_ERROR);
                 }
                 else
                 {
@@ -646,8 +647,8 @@
             }
             else
             {
-                sprintf(status_line_str, "HTTP/1.1 500 Internal Server Error\
-                        \r\n");
+                sprintf(status_line_str, "%s %s\r\n", "HTTP/1.1",
+                        AXIS2_HTTP_RESPONSE_INTERNAL_SERVER_ERROR);
             }
 
             tmp_stat_line = axis2_http_status_line_create(env, status_line_str);
@@ -681,7 +682,7 @@
     {
         axis2_http_simple_response_set_status_line(response, env, http_version,
                                                    AXIS2_HTTP_RESPONSE_OK_CODE_VAL,
-                                                   "OK");
+                                                   AXIS2_HTTP_RESPONSE_OK_CODE_NAME);
         if (!is_head)
         {
             axis2_http_simple_response_set_body_stream(response, env, out_stream);
@@ -691,7 +692,7 @@
     {
         axis2_http_simple_response_set_status_line(response, env, http_version,
                                                    AXIS2_HTTP_RESPONSE_ACK_CODE_VAL,
-                                                   "Accepted");
+                                                   AXIS2_HTTP_RESPONSE_ACK_CODE_NAME);
     }
     axis2_http_worker_set_response_headers(http_worker, env, svr_conn,
                                            simple_request, response,

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=637455&r1=637454&r2=637455&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 Sat
Mar 15 12:35:56 2008
@@ -317,7 +317,7 @@
             {
                 body_string =
                     axis2_http_transport_utils_get_services_html(env, conf_ctx);
-                request->content_type = "text/html";
+                request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
             }
             else if (M_DELETE != request->method_number && wsdl)
             {
@@ -327,7 +327,7 @@
                                                                         (axis2_char_t
                                                                          *)
                                                                         req_url);
-                request->content_type = "text/xml";
+                request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_XML;
                            
             }
             else if (env->error->error_number == AXIS2_ERROR_SVC_OR_OP_NOT_FOUND)
@@ -345,28 +345,28 @@
                     request->allowed = 0;
                     for (i = 0; i < size; i++)
                     {
-                        if (!strcasecmp("PUT", (axis2_char_t *) 
+                        if (!strcasecmp(AXIS2_HTTP_PUT, (axis2_char_t *) 
                                 axutil_array_list_get(method_list, env, i)))
                         {
                             request->allowed |= AP_METHOD_BIT << M_PUT;
                         }
-                        else if (!strcasecmp("POST", (axis2_char_t *) 
+                        else if (!strcasecmp(AXIS2_HTTP_POST, (axis2_char_t *) 
                                 axutil_array_list_get(method_list, env, i)))
                         {
                             request->allowed |= AP_METHOD_BIT << M_POST;
                         }
-                        else if (!strcasecmp("GET", (axis2_char_t *) 
+                        else if (!strcasecmp(AXIS2_HTTP_GET, (axis2_char_t *) 
                                 axutil_array_list_get(method_list, env, i)))
                         {
                             request->allowed |= AP_METHOD_BIT << M_GET;
                         }
-                        else if (!strcasecmp("HEAD", (axis2_char_t *) 
+                        else if (!strcasecmp(AXIS2_HTTP_HEAD, (axis2_char_t *) 
                                 axutil_array_list_get(method_list, env, i)))
                         {
                             /* Apache Can't differentiate between HEAD and GET */
                             request->allowed |= AP_METHOD_BIT << M_GET;
                         }
-                        else if (!strcasecmp("DELETE", (axis2_char_t *) 
+                        else if (!strcasecmp(AXIS2_HTTP_DELETE, (axis2_char_t *) 
                                 axutil_array_list_get(method_list, env, i)))
                         {
                             request->allowed |= AP_METHOD_BIT << M_DELETE;
@@ -374,21 +374,21 @@
                     }
                     body_string =
                         axis2_http_transport_utils_get_method_not_allowed(env, conf_ctx);
-                    request->status = 405;
+                    request->status = HTTP_METHOD_NOT_ALLOWED;
                 }
                 else
                 {
                     body_string =
                         axis2_http_transport_utils_get_not_found(env, conf_ctx);
-                    request->status = 404;
+                    request->status = HTTP_NOT_FOUND;
                 }
-                request->content_type = "text/html";
+                request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
             }
             else
             {
                 body_string =
                     axis2_http_transport_utils_get_services_html(env, conf_ctx);
-                request->content_type = "text/html";
+                request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
                 request->status = HTTP_INTERNAL_SERVER_ERROR;
             }
 
@@ -421,16 +421,63 @@
         {
             if (env->error->error_number == AXIS2_ERROR_SVC_OR_OP_NOT_FOUND)
             {
-                body_string =
-                    axis2_http_transport_utils_get_not_found(env, conf_ctx);
-                request->content_type = "text/html";
-                request->status = 404;
+                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)
+                {
+                    int i = 0;
+                    /* The "Allow" header doesn't show up at the moment.
+                     * This needs to be fixed ASAP.
+                     */
+                    request->allowed = 0;
+                    for (i = 0; i < size; i++)
+                    {
+                        if (!strcasecmp(AXIS2_HTTP_PUT, (axis2_char_t *) 
+                                axutil_array_list_get(method_list, env, i)))
+                        {
+                            request->allowed |= AP_METHOD_BIT << M_PUT;
+                        }
+                        else if (!strcasecmp(AXIS2_HTTP_POST, (axis2_char_t *) 
+                                axutil_array_list_get(method_list, env, i)))
+                        {
+                            request->allowed |= AP_METHOD_BIT << M_POST;
+                        }
+                        else if (!strcasecmp(AXIS2_HTTP_GET, (axis2_char_t *) 
+                                axutil_array_list_get(method_list, env, i)))
+                        {
+                            request->allowed |= AP_METHOD_BIT << M_GET;
+                        }
+                        else if (!strcasecmp(AXIS2_HTTP_HEAD, (axis2_char_t *) 
+                                axutil_array_list_get(method_list, env, i)))
+                        {
+                            /* Apache Can't differentiate between HEAD and GET */
+                            request->allowed |= AP_METHOD_BIT << M_GET;
+                        }
+                        else if (!strcasecmp(AXIS2_HTTP_DELETE, (axis2_char_t *) 
+                                axutil_array_list_get(method_list, env, i)))
+                        {
+                            request->allowed |= AP_METHOD_BIT << M_DELETE;
+                        }
+                    }
+                    body_string =
+                        axis2_http_transport_utils_get_method_not_allowed(env, conf_ctx);
+                    request->status = HTTP_METHOD_NOT_ALLOWED;
+                }
+                else
+                {
+                    body_string =
+                        axis2_http_transport_utils_get_not_found(env, conf_ctx);
+                    request->status = HTTP_NOT_FOUND;
+                }
+                request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
             }
             else
             {
                 body_string =
                     axis2_http_transport_utils_get_services_html(env, conf_ctx);
-                request->content_type = "text/html";
+                request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
                 request->status = HTTP_INTERNAL_SERVER_ERROR;
             }
 



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


Mime
View raw message