1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-07 04:02:58 +03:00

core: follow up to r1876664: allow ErrorDocument to read body when applicable

Unless ap_read_request() failed to read the request line or header, or
Transfer-Encoding is invalid, we can still provide the request body to custom
error handlers (ErrorDocument) that ask it (e.g. internal redirects to CGI).

So this commit splits early failure path (previously die_early label) in two,
die_unusable_input and die_before_hooks, where the latter preserves input
filters (including HTTP_IN).

Also, the code to apply the connection timeout and r->per_dir_config from the
server is now in a new apply_server_config() helper since it's used multiple
times. Note that apr_socket_timeout_set() is a noop if the new timeout is the
same as the one already in place, so there is no need to cache the old timeout
nor use apr_socket_timeout_get(). Likewise, r->server is initially set to
c->base_server so apply_server_config() is overall a noop when no change is
needed.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1876784 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yann Ylavic
2020-04-21 10:29:07 +00:00
parent 3fce584ad1
commit ac762c1ae1
2 changed files with 47 additions and 40 deletions

View File

@@ -289,6 +289,8 @@ request_rec *h2_request_create_rec(const h2_request *req, conn_rec *c)
/* Validate HTTP/1 request and select vhost. */
if (!ap_parse_request_line(r) || !ap_check_request_header(r)) {
/* we may have switched to another server still */
r->per_dir_config = r->server->lookup_defaults;
access_status = r->status;
r->status = HTTP_OK;
goto die;
@@ -328,12 +330,12 @@ die:
* end the request with an EOR bucket for stream/pipeline accounting.
*/
{
apr_bucket_brigade *tmp_bb;
tmp_bb = ap_acquire_brigade(c);
APR_BRIGADE_INSERT_TAIL(tmp_bb,
apr_bucket_brigade *eor_bb;
eor_bb = ap_acquire_brigade(c);
APR_BRIGADE_INSERT_TAIL(eor_bb,
ap_bucket_eor_create(c->bucket_alloc, r));
ap_pass_brigade(c->output_filters, tmp_bb);
ap_release_brigade(c, tmp_bb);
ap_pass_brigade(c->output_filters, eor_bb);
ap_release_brigade(c, eor_bb);
}
r = NULL;