From fbb84e00fa53ca34b97f9acc4d024e512d4e6f23 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Wed, 13 Apr 2022 07:40:17 +0000 Subject: Merge PR 311: *) core/mod_http: use REQUEST meta buckets and a new HTTP/1.x specific input filter to separate the handling for HTTP requests from the handling of HTTP/1.x request parsing and checks. A new HTTP1_REQUEST_IN filter installs itself on http/1.1 connections before a request is being read. It generates either a REQUEST meta bucket on success or an ERROR bucket with the proposed response status. The core connection processing, relying on ap_read_request(), now expects a REQUEST or ERROR bucket from the input filters and is agnostic to specific HTTP versions and how they bring requests into the server. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1899799 13f79535-47bb-0310-9956-ffa450edef68 --- include/ap_mmn.h | 2 +- include/http_protocol.h | 24 +++++++++++++++++++----- include/mod_core.h | 5 +++++ 3 files changed, 25 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 25fa16e963..7b6753cbe4 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -708,7 +708,7 @@ * 20211221.6 (2.5.1-dev) Add new meta buckets request/response/headers * Add field `body_indeterminate` in request_rec * Add new http/1.x formatting helpers - * Add ap_assign_request() + * Add ap_assign_request_line() * 20211221.7 (2.5.1-dev) Add ap_h1_append_header() */ diff --git a/include/http_protocol.h b/include/http_protocol.h index a2113d99d3..4bfe4a8559 100644 --- a/include/http_protocol.h +++ b/include/http_protocol.h @@ -65,19 +65,33 @@ AP_DECLARE(request_rec *) ap_create_request(conn_rec *c); * @param c The current connection * @return The new request_rec */ -request_rec *ap_read_request(conn_rec *c); +AP_DECLARE(request_rec *) ap_read_request(conn_rec *c); /** - * Assign the method, uri and protocol to the request. + * Assign the method, uri and protocol (in HTTP/1.x the + * items from the first line) to the request. * @param r The current request * @param method the HTTP method * @param uri the request uri * @param protocol the request protocol * @return 1 on success, 0 on failure */ -AP_DECLARE(int) ap_assign_request(request_rec *r, - const char *method, const char *uri, - const char *protocol); +AP_DECLARE(int) ap_assign_request_line(request_rec *r, + const char *method, const char *uri, + const char *protocol); + +/** + * Parse a HTTP/1.x request line, validate and return the components + * @param r The current request + * @param line the line to parse + * @param pmethod the parsed method on success + * @param puri the parsed uri on success + * @param pprotocol the parsed protocol on success + * @return 1 on success, 0 on failure + */ +AP_DECLARE(int) ap_h1_tokenize_request_line( + request_rec *r, const char *line, + const char **pmethod, const char **puri, const char **pprotocol); /** * Parse and validate the request line. diff --git a/include/mod_core.h b/include/mod_core.h index 0c795ceeee..f9cc0611f4 100644 --- a/include/mod_core.h +++ b/include/mod_core.h @@ -41,6 +41,7 @@ extern "C" { /* Handles for core filters */ AP_DECLARE_DATA extern ap_filter_rec_t *ap_http_input_filter_handle; +AP_DECLARE_DATA extern ap_filter_rec_t *ap_h1_request_in_filter_handle; AP_DECLARE_DATA extern ap_filter_rec_t *ap_h1_body_in_filter_handle; AP_DECLARE_DATA extern ap_filter_rec_t *ap_http_header_filter_handle; AP_DECLARE_DATA extern ap_filter_rec_t *ap_chunk_filter_handle; @@ -54,6 +55,10 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes); +apr_status_t ap_h1_request_in_filter(ap_filter_t *f, apr_bucket_brigade *bb, + ap_input_mode_t mode, apr_read_type_e block, + apr_off_t readbytes); + apr_status_t ap_h1_body_in_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes); -- cgit v1.2.1