From: Ruediger Pluem Date: Thu, 31 Mar 2022 20:10:21 +0000 (+0000) Subject: * In case we see an EOC bucket and there was an error bucket before, use its X-Git-Tag: 2.5.0-alpha2-ci-test-only~423 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=885a08dc2eadbca9182a89e75ef6028b65827ff9;p=thirdparty%2Fapache%2Fhttpd.git * In case we see an EOC bucket and there was an error bucket before, use its status as status for the request. This should ensure proper status logging in the access log. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1899454 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/http/http_filters.c b/modules/http/http_filters.c index dbdd515592e..d41a519b500 100644 --- a/modules/http/http_filters.c +++ b/modules/http/http_filters.c @@ -1802,6 +1802,7 @@ AP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, /* Context struct for ap_http_outerror_filter */ typedef struct { int seen_eoc; + int first_error; } outerror_filter_ctx_t; /* Filter to handle any error buckets on output */ @@ -1831,12 +1832,26 @@ apr_status_t ap_http_outerror_filter(ap_filter_t *f, /* stream aborted and we have not ended it yet */ r->connection->keepalive = AP_CONN_CLOSE; } + /* + * Memorize the status code of the first error bucket for possible + * later use. + */ + if (!ctx->first_error) { + ctx->first_error = ((ap_bucket_error *)(e->data))->status; + } continue; } /* Detect EOC buckets and memorize this in the context. */ if (AP_BUCKET_IS_EOC(e)) { r->connection->keepalive = AP_CONN_CLOSE; ctx->seen_eoc = 1; + /* Set the request status to the status of the first error bucket. + * This should ensure that we log an appropriate status code in + * the access log. + */ + if (ctx->first_error) { + r->status = ctx->first_error; + } } } /*