You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by yl...@apache.org on 2016/12/12 16:14:50 UTC
svn commit: r1773812 - /httpd/httpd/trunk/modules/http/http_filters.c
Author: ylavic
Date: Mon Dec 12 16:14:50 2016
New Revision: 1773812
URL: http://svn.apache.org/viewvc?rev=1773812&view=rev
Log:
Follow up to r1773761: don't recurse on internal redirects.
Modified:
httpd/httpd/trunk/modules/http/http_filters.c
Modified: httpd/httpd/trunk/modules/http/http_filters.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http/http_filters.c?rev=1773812&r1=1773811&r2=1773812&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http/http_filters.c (original)
+++ httpd/httpd/trunk/modules/http/http_filters.c Mon Dec 12 16:14:50 2016
@@ -1201,16 +1201,13 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_
}
if (ctx->headers_sent) {
+ /* Eat body if response must not have one. */
if (r->header_only || r->status == HTTP_NO_CONTENT) {
- /* r->header_only or HTTP_NO_CONTENT case below, don't let
- * the body pass trhough.
- */
apr_brigade_cleanup(b);
return APR_SUCCESS;
}
}
else if (!ctx->headers_error && !check_headers(r)) {
- /* Eat body until EOS */
ctx->headers_error = 1;
}
for (e = APR_BRIGADE_FIRST(b);
@@ -1238,21 +1235,38 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_
}
}
if (ctx->headers_error) {
- /* We'll come back here from ap_send_error_response(),
- * so clear anything from this response.
- */
- apr_brigade_cleanup(b);
if (!eos) {
+ /* Eat body until EOS */
+ apr_brigade_cleanup(b);
return APR_SUCCESS;
}
+
+ /* We may come back here from ap_die() below,
+ * so clear anything from this response.
+ */
ctx->headers_error = 0;
apr_table_clear(r->headers_out);
apr_table_clear(r->err_headers_out);
+
+ /* Don't try ErrorDocument if we are (internal-)redirect-ed already,
+ * otherwise we can end up in infinite recursion, better fall through
+ * with 500, minimal headers and an empty body (EOS only).
+ */
+ if (ap_is_initial_req(r)) {
+ apr_brigade_cleanup(b);
+ ap_die(HTTP_INTERNAL_SERVER_ERROR, r);
+ return AP_FILTER_ERROR;
+ }
+ AP_DEBUG_ASSERT(APR_BUCKET_IS_EOS(e));
+ APR_BUCKET_REMOVE(e);
+ apr_brigade_cleanup(b);
+ APR_BRIGADE_INSERT_TAIL(b, e);
r->status = HTTP_INTERNAL_SERVER_ERROR;
- ap_send_error_response(r, 0);
- return AP_FILTER_ERROR;
+ r->content_type = r->content_encoding = NULL;
+ r->content_languages = NULL;
+ ap_set_content_length(r, 0);
}
- if (eb) {
+ else if (eb) {
int status;
status = eb->status;
apr_brigade_cleanup(b);