httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r556973 - in /httpd/httpd/branches/2.2.x/modules/generators: mod_cgi.c mod_cgid.c
Date Tue, 17 Jul 2007 17:16:12 GMT
Author: jim
Date: Tue Jul 17 10:16:09 2007
New Revision: 556973

URL: http://svn.apache.org/viewvc?view=rev&rev=556973
Log:
Merge r541926, r541990 from trunk:

PR#39710 - badly broken errordocuments for CGI

We've just had another duplicate report of this on bugzilla.
We've got a simple patch, and people asking WTF is going on
with inaction.  Noone seems clear on why the patch shouldn't
be applied (http://marc.info/?l=apache-httpd-dev&m=117760311129386&w=2).


* Prevent running through the error stack by returning OK and setting r->status
  accordingly if ret is HTTP_NOT_MODIFIED as this breaks mod_cache validating a
  stale entity.

Reviewed by: jim

Modified:
    httpd/httpd/branches/2.2.x/modules/generators/mod_cgi.c
    httpd/httpd/branches/2.2.x/modules/generators/mod_cgid.c

Modified: httpd/httpd/branches/2.2.x/modules/generators/mod_cgi.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/generators/mod_cgi.c?view=diff&rev=556973&r1=556972&r2=556973
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/generators/mod_cgi.c (original)
+++ httpd/httpd/branches/2.2.x/modules/generators/mod_cgi.c Tue Jul 17 10:16:09 2007
@@ -926,14 +926,30 @@
         if ((ret = ap_scan_script_header_err_brigade(r, bb, sbuf))) {
             ret = log_script(r, conf, ret, dbuf, sbuf, bb, script_err);
 
-            /* Set our status. */
-            r->status = ret;
-
-            /* Pass EOS bucket down the filter chain. */
-            apr_brigade_cleanup(bb);
-            b = apr_bucket_eos_create(c->bucket_alloc);
-            APR_BRIGADE_INSERT_TAIL(bb, b);
-            ap_pass_brigade(r->output_filters, bb);
+            /*
+             * ret could be HTTP_NOT_MODIFIED in the case that the CGI script
+             * does not set an explicit status and ap_meets_conditions, which
+             * is called by ap_scan_script_header_err_brigade, detects that
+             * the conditions of the requests are met and the response is
+             * not modified.
+             * In this case set r->status and return OK in order to prevent
+             * running through the error processing stack as this would
+             * break with mod_cache, if the conditions had been set by
+             * mod_cache itself to validate a stale entity.
+             * BTW: We circumvent the error processing stack anyway if the
+             * CGI script set an explicit status code (whatever it is) and
+             * the only possible values for ret here are:
+             *
+             * HTTP_NOT_MODIFIED          (set by ap_meets_conditions)
+             * HTTP_PRECONDITION_FAILED   (set by ap_meets_conditions)
+             * HTTP_INTERNAL_SERVER_ERROR (if something went wrong during the
+             * processing of the response of the CGI script, e.g broken headers
+             * or a crashed CGI process).
+             */
+            if (ret == HTTP_NOT_MODIFIED) {
+                r->status = ret;
+                return OK;
+            }
 
             return ret;
         }

Modified: httpd/httpd/branches/2.2.x/modules/generators/mod_cgid.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/generators/mod_cgid.c?view=diff&rev=556973&r1=556972&r2=556973
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/generators/mod_cgid.c (original)
+++ httpd/httpd/branches/2.2.x/modules/generators/mod_cgid.c Tue Jul 17 10:16:09 2007
@@ -1467,7 +1467,34 @@
         APR_BRIGADE_INSERT_TAIL(bb, b);
 
         if ((ret = ap_scan_script_header_err_brigade(r, bb, sbuf))) {
-            return log_script(r, conf, ret, dbuf, sbuf, bb, NULL);
+            ret = log_script(r, conf, ret, dbuf, sbuf, bb, NULL);
+
+            /*
+             * ret could be HTTP_NOT_MODIFIED in the case that the CGI script
+             * does not set an explicit status and ap_meets_conditions, which
+             * is called by ap_scan_script_header_err_brigade, detects that
+             * the conditions of the requests are met and the response is
+             * not modified.
+             * In this case set r->status and return OK in order to prevent
+             * running through the error processing stack as this would
+             * break with mod_cache, if the conditions had been set by
+             * mod_cache itself to validate a stale entity.
+             * BTW: We circumvent the error processing stack anyway if the
+             * CGI script set an explicit status code (whatever it is) and
+             * the only possible values for ret here are:
+             *
+             * HTTP_NOT_MODIFIED          (set by ap_meets_conditions)
+             * HTTP_PRECONDITION_FAILED   (set by ap_meets_conditions)
+             * HTTP_INTERNAL_SERVER_ERROR (if something went wrong during the
+             * processing of the response of the CGI script, e.g broken headers
+             * or a crashed CGI process).
+             */
+            if (ret == HTTP_NOT_MODIFIED) {
+                r->status = ret;
+                return OK;
+            }
+
+            return ret;
         }
 
         location = apr_table_get(r->headers_out, "Location");



Mime
View raw message