1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-05 16:55:50 +03:00

Process early errors via a dummy HTTP/1.1 request as well

Process early errors via a dummy HTTP/1.1 request as well to ensure
that the request gets logged correctly and possible custom error
pages are considered. The previous way of directly sending a HTTP/2
answer with the HTTP status code appropriate for the error is more
efficient, but does not log the request nor sents a possible custom
error page.

* modules/http2/h2.h: Add http_status to h2_request struct and define
  H2_HTTP_STATUS_UNSET.

* modules/http2/h2_request.c(h2_request_create_rec): Check if
  http_status is set for the request and die with the
  status code it contains if set.

* modules/http2/h2_session.c(on_header_cb): Adjust the error condition
  now that we mark early errors via http_status: Only return an error
  if the status is not success and http_status is not H2_HTTP_STATUS_UNSET.

* modules/http2/h2_stream.c(set_error_response): Set http_status
  on the request instead of creating headers for a response and a
  respective brigade.

Github: closes #137


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1881620 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ruediger Pluem
2020-09-10 10:45:12 +00:00
parent f077e9a2b2
commit a4fba22366
4 changed files with 37 additions and 17 deletions

View File

@@ -79,11 +79,12 @@ apr_status_t h2_request_rcreate(h2_request **preq, apr_pool_t *pool,
}
req = apr_pcalloc(pool, sizeof(*req));
req->method = apr_pstrdup(pool, r->method);
req->scheme = scheme;
req->authority = authority;
req->path = path;
req->headers = apr_table_make(pool, 10);
req->method = apr_pstrdup(pool, r->method);
req->scheme = scheme;
req->authority = authority;
req->path = path;
req->headers = apr_table_make(pool, 10);
req->http_status = H2_HTTP_STATUS_UNSET;
if (r->server) {
req->serialize = h2_config_rgeti(r, H2_CONF_SER_HEADERS);
}
@@ -294,7 +295,14 @@ request_rec *h2_request_create_rec(const h2_request *req, conn_rec *c)
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;
if (req->http_status != H2_HTTP_STATUS_UNSET) {
access_status = req->http_status;
/* Be safe and close the connection */
c->keepalive = AP_CONN_CLOSE;
}
else {
access_status = r->status;
}
r->status = HTTP_OK;
goto die;
}
@@ -302,6 +310,14 @@ request_rec *h2_request_create_rec(const h2_request *req, conn_rec *c)
/* we may have switched to another server */
r->per_dir_config = r->server->lookup_defaults;
if (req->http_status != H2_HTTP_STATUS_UNSET) {
access_status = req->http_status;
r->status = HTTP_OK;
/* Be safe and close the connection */
c->keepalive = AP_CONN_CLOSE;
goto die;
}
/*
* Add the HTTP_IN filter here to ensure that ap_discard_request_body
* called by ap_die and by ap_send_error_response works correctly on