tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r698229 - in /tomcat/connectors/trunk/jk: native/apache-2.0/mod_jk.c native/common/jk_ajp_common.c native/common/jk_service.h native/common/jk_util.c xdocs/miscellaneous/changelog.xml
Date Tue, 23 Sep 2008 16:37:44 GMT
Author: mturk
Date: Tue Sep 23 09:37:44 2008
New Revision: 698229

URL: http://svn.apache.org/viewvc?rev=698229&view=rev
Log:
Add use_server_errors extension so server error pages can be displayed instead the one generated
by Tomcat. Only Apache 2 for the moment

Modified:
    tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c
    tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c
    tomcat/connectors/trunk/jk/native/common/jk_service.h
    tomcat/connectors/trunk/jk/native/common/jk_util.c
    tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml

Modified: tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c?rev=698229&r1=698228&r2=698229&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c (original)
+++ tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c Tue Sep 23 09:37:44 2008
@@ -688,6 +688,7 @@
     e = (rule_extension_t *)ap_get_module_config(r->request_config, &jk_module);
     if (e) {
         s->extension.reply_timeout = e->reply_timeout;
+        s->extension.use_server_error_pages = e->use_server_error_pages;
         if (e->activation) {
             s->extension.activation = apr_palloc(r->pool, e->activation_size * sizeof(int));
             memcpy(s->extension.activation, e->activation, e->activation_size *
sizeof(int));
@@ -2364,7 +2365,10 @@
                     end->done(&end, xconf->log);
                     if (s.content_read < s.content_length ||
                         (s.is_chunked && !s.no_more_chunks)) {
-
+                        if (JK_IS_DEBUG_LEVEL(xconf->log))
+                           jk_log(xconf->log, JK_LOG_DEBUG,
+                                  "Consuming remaining request data for worker=%s",
+                                  STRNULL_FOR_NULL(worker_name));
                         /*
                          * If the servlet engine didn't consume all of the
                          * request data, consume and discard all further
@@ -2411,6 +2415,15 @@
             jk_close_pool(&private_data.p);
 
             if (rc > 0) {
+                if (s.extension.use_server_error_pages &&
+                    s.http_response_status >= s.extension.use_server_error_pages) {
+                    if (JK_IS_DEBUG_LEVEL(xconf->log))
+                        jk_log(xconf->log, JK_LOG_DEBUG, "Forwarding status=%d"
+                               " for worker=%s",
+                               s.http_response_status, worker_name);
+                    JK_TRACE_EXIT(xconf->log);
+                    return s.http_response_status;
+                }
                 /* If tomcat returned no body and the status is not OK,
                    let apache handle the error code */
 

Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c?rev=698229&r1=698228&r2=698229&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c Tue Sep 23 09:37:44 2008
@@ -1656,17 +1656,24 @@
                 JK_TRACE_EXIT(l);
                 return JK_STATUS_ERROR;
             }
-            r->start_response(r, res.status, res.msg,
-                              (const char *const *)res.header_names,
-                              (const char *const *)res.header_values,
-                              res.num_headers);
-            if (r->flush && r->flush_header)
-                r->flush(r);
+
+            if (r->extension.use_server_error_pages &&
+                r->http_response_status >= r->extension.use_server_error_pages)
+                r->response_blocked = JK_TRUE;
+
+            if (!r->response_blocked) {
+                r->start_response(r, res.status, res.msg,
+                                  (const char *const *)res.header_names,
+                                  (const char *const *)res.header_values,
+                                  res.num_headers);
+                if (r->flush && r->flush_header)
+                    r->flush(r);
+            }
         }
         return JK_AJP13_SEND_HEADERS;
 
     case JK_AJP13_SEND_BODY_CHUNK:
-        {
+        if (!r->response_blocked) {
             unsigned int len = (unsigned int)jk_b_get_int(msg);
             /*
              * Do a sanity check on len to prevent write reading beyond buffer
@@ -1762,15 +1769,16 @@
             }
             ae->reuse = JK_TRUE;
         }
-        if (r->done) {
-            /* Done with response */
-            r->done(r);
-        }
-        else if (r->flush && !r->flush_packets) {
-            /* Flush after the last write */
-            r->flush(r);
+        if (!r->response_blocked) {
+            if (r->done) {
+                /* Done with response */
+                r->done(r);
+            }
+            else if (r->flush && !r->flush_packets) {
+                /* Flush after the last write */
+                r->flush(r);
+            }
         }
-
         JK_TRACE_EXIT(l);
         return JK_AJP13_END_RESPONSE;
         break;

Modified: tomcat/connectors/trunk/jk/native/common/jk_service.h
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_service.h?rev=698229&r1=698228&r2=698229&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_service.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_service.h Tue Sep 23 09:37:44 2008
@@ -87,6 +87,8 @@
     int fail_on_status_size;
     /* Dynamically allocated array with one entry per status. */
     int *fail_on_status;
+    /* Use server error pages for responses >= 400. */
+    int use_server_error_pages;
 };
 typedef struct svc_extension svc_extension_t;
 
@@ -247,6 +249,11 @@
     int response_started;
 
     /*
+     * JK_TRUE if response should not be send to the client
+     */
+    int response_blocked;
+
+    /*
      * HTTP status sent from container.
      */
     int http_response_status;

Modified: tomcat/connectors/trunk/jk/native/common/jk_util.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_util.c?rev=698229&r1=698228&r2=698229&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_util.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_util.c Tue Sep 23 09:37:44 2008
@@ -1962,10 +1962,12 @@
     s->flush_packets = JK_FALSE;
     s->flush_header = JK_FALSE;
     s->extension.reply_timeout = -1;
+    s->extension.use_server_error_pages = 0;
     s->extension.activation = NULL;
     s->extension.fail_on_status_size = 0;
     s->extension.fail_on_status = NULL;
     s->response_started = JK_FALSE;
+    s->response_blocked = JK_FALSE;
     s->http_response_status = JK_HTTP_OK;
     s->uw_map = NULL;
     s->start_response = NULL;

Modified: tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml?rev=698229&r1=698228&r2=698229&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml (original)
+++ tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml Tue Sep 23 09:37:44 2008
@@ -44,6 +44,11 @@
   <subsection name="Native">
     <changelog>
       <update>
+        Allow forwarding server error pages. This can be done
+        on per-uri basis using new use_server_errors extension.
+        (mturk)
+      </update>
+      <update>
         Added session_cookie and session_path for configuring
         default session identifiers. (mturk)
       </update>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message