From 2311f5561e9848e3baa9fe8f457b54a50d565d41 Mon Sep 17 00:00:00 2001 From: Greg Ames Date: Wed, 18 Oct 2000 15:21:32 +0000 Subject: [PATCH] Add a core_request_config so we have a safe semi-hidden place to save core data that lives across function calls during a single request. Change getline() to take a request_rec parm (rather than a conn_rec) so we can access the core_request_config. This is in preparation for adding look-ahead functionality to getline(), so it can support header line folding once again. I'm committing these changes first so the core_request_config can be used elsewhere (i.e. ap_get_client_block). git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86642 13f79535-47bb-0310-9956-ffa450edef68 --- include/http_core.h | 7 +++++++ modules/http/http_protocol.c | 16 ++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/http_core.h b/include/http_core.h index f5b739bb07..a4028f9520 100644 --- a/include/http_core.h +++ b/include/http_core.h @@ -318,6 +318,13 @@ char *ap_response_code_string (request_rec *r, int error_index); extern AP_DECLARE_DATA module core_module; +/* Per-request configuration */ + +typedef struct { + /* bucket brigade used by getline for look-ahead */ + struct ap_bucket_brigade *bb; +} core_request_config; + /* Per-directory configuration */ typedef unsigned char allow_options_t; diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index 66a4f3495b..943f5bf4ec 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -847,7 +847,7 @@ struct dechunk_ctx { }; static long get_chunk_size(char *); -static int getline(char *s, int n, conn_rec *c, int fold); +static int getline(char *s, int n, request_rec *r, int fold); apr_status_t dechunk_filter(ap_filter_t *f, ap_bucket_brigade *bb, apr_ssize_t length) @@ -871,7 +871,7 @@ apr_status_t dechunk_filter(ap_filter_t *f, ap_bucket_brigade *bb, */ char line[30]; - if ((rv = getline(line, sizeof(line), f->c, 0)) < 0) { + if ((rv = getline(line, sizeof(line), f->r, 0)) < 0) { return rv; } switch(ctx->state) { @@ -1031,7 +1031,7 @@ apr_status_t http_filter(ap_filter_t *f, ap_bucket_brigade *b, apr_ssize_t lengt * then the actual input line exceeded the buffer length, * and it would be a good idea for the caller to puke 400 or 414. */ -static int getline(char *s, int n, conn_rec *c, int fold) +static int getline(char *s, int n, request_rec *r, int fold) { char *pos = s; char *last_char; @@ -1040,6 +1040,7 @@ static int getline(char *s, int n, conn_rec *c, int fold) int retval; int total = 0; apr_ssize_t length; + conn_rec *c = r->connection; ap_bucket_brigade *b; ap_bucket *e; @@ -1200,7 +1201,7 @@ static int read_request_line(request_rec *r) */ ap_bsetflag(conn->client, B_SAFEREAD, 1); ap_bflush(conn->client); - while ((len = getline(l, sizeof(l), conn, 0)) <= 0) { + while ((len = getline(l, sizeof(l), r, 0)) <= 0) { if (len < 0) { /* includes EOF */ ap_bsetflag(conn->client, B_SAFEREAD, 0); /* this is a hack to make sure that request time is set, @@ -1267,7 +1268,6 @@ static int read_request_line(request_rec *r) static void get_mime_headers(request_rec *r) { char field[DEFAULT_LIMIT_REQUEST_FIELDSIZE + 2]; /* getline's two extra */ - conn_rec *c = r->connection; char *value; char *copy; int len; @@ -1281,7 +1281,7 @@ static void get_mime_headers(request_rec *r) * Read header lines until we get the empty separator line, a read error, * the connection closes (EOF), reach the server limit, or we timeout. */ - while ((len = getline(field, sizeof(field), c, 1)) > 0) { + while ((len = getline(field, sizeof(field), r, 1)) > 0) { if (r->server->limit_req_fields && (++fields_read > r->server->limit_req_fields)) { @@ -1339,6 +1339,7 @@ request_rec *ap_read_request(conn_rec *conn) apr_pool_t *p; const char *expect; int access_status; + core_request_config *req_cfg; apr_create_pool(&p, conn->pool); r = apr_pcalloc(p, sizeof(request_rec)); @@ -1361,6 +1362,9 @@ request_rec *ap_read_request(conn_rec *conn) r->notes = apr_make_table(r->pool, 5); r->request_config = ap_create_request_config(r->pool); + req_cfg = apr_pcalloc(r->pool, sizeof(core_request_config)); + ap_set_module_config(r->request_config, &core_module, req_cfg); + r->per_dir_config = r->server->lookup_defaults; r->sent_bodyct = 0; /* bytect isn't for body */ -- 2.40.0