[core] move addtl request-specific struct members
This commit is contained in:
parent
100dfaa3f3
commit
a22cdca1cb
|
@ -14,7 +14,6 @@
|
|||
#include "sock_addr.h"
|
||||
|
||||
struct fdevents; /* declaration */
|
||||
struct stat_cache; /* declaration */
|
||||
|
||||
#define DIRECT 0 /* con->mode */
|
||||
|
||||
|
@ -108,8 +107,6 @@ struct connection {
|
|||
physical physical;
|
||||
response response;
|
||||
|
||||
array environment; /* used to pass lighttpd internal stuff to the FastCGI/CGI apps, setenv does that */
|
||||
|
||||
int mode; /* DIRECT (0) or plugin id */
|
||||
|
||||
server *srv;
|
||||
|
@ -121,10 +118,6 @@ struct connection {
|
|||
|
||||
uint16_t proto_default_port;
|
||||
|
||||
/* error-handler */
|
||||
int error_handler_saved_status;
|
||||
http_method_t error_handler_saved_method;
|
||||
|
||||
struct server_socket *srv_socket; /* reference to the server-socket */
|
||||
int (* network_write)(struct connection *con, chunkqueue *cq, off_t max_bytes);
|
||||
int (* network_read)(struct connection *con, chunkqueue *cq, off_t max_bytes);
|
||||
|
|
|
@ -271,8 +271,8 @@ static void connection_handle_errdoc_init(connection *con) {
|
|||
__attribute_cold__
|
||||
static void connection_handle_errdoc(connection *con) {
|
||||
if (con->mode == DIRECT
|
||||
? con->error_handler_saved_status >= 65535
|
||||
: (!con->conf.error_intercept || con->error_handler_saved_status))
|
||||
? con->request.error_handler_saved_status >= 65535
|
||||
: (!con->conf.error_intercept||con->request.error_handler_saved_status))
|
||||
return;
|
||||
|
||||
connection_handle_errdoc_init(con);
|
||||
|
@ -603,7 +603,7 @@ void connections_free(server *srv) {
|
|||
chunkqueue_free(con->request.reqbody_queue);
|
||||
array_free_data(&con->request.headers);
|
||||
array_free_data(&con->response.headers);
|
||||
array_free_data(&con->environment);
|
||||
array_free_data(&con->request.env);
|
||||
|
||||
#define CLEAN(x) \
|
||||
buffer_free(con->x);
|
||||
|
@ -683,8 +683,8 @@ static int connection_reset(connection *con) {
|
|||
else
|
||||
array_reset_data_strings(&con->request.headers);
|
||||
con->request.rqst_header_len = 0;
|
||||
if (0 != con->environment.used)
|
||||
array_reset_data_strings(&con->environment);
|
||||
if (0 != con->request.env.used)
|
||||
array_reset_data_strings(&con->request.env);
|
||||
|
||||
chunkqueue_reset(con->request.reqbody_queue);
|
||||
|
||||
|
@ -692,8 +692,8 @@ static int connection_reset(connection *con) {
|
|||
/* config_cond_cache_reset(con); */
|
||||
|
||||
con->request.async_callback = 0;
|
||||
con->error_handler_saved_status = 0;
|
||||
/*con->error_handler_saved_method = HTTP_METHOD_UNSET;*/
|
||||
con->request.error_handler_saved_status = 0;
|
||||
/*con->request.error_handler_saved_method = HTTP_METHOD_UNSET;*/
|
||||
/*(error_handler_saved_method value is not valid unless error_handler_saved_status is set)*/
|
||||
|
||||
config_reset_config(con);
|
||||
|
@ -1145,17 +1145,17 @@ static int connection_handle_request(connection *con) {
|
|||
/* fall through */
|
||||
case HANDLER_FINISHED:
|
||||
if (con->http_status == 0) con->http_status = 200;
|
||||
if (con->error_handler_saved_status > 0) {
|
||||
con->request.http_method = con->error_handler_saved_method;
|
||||
if (con->request.error_handler_saved_status > 0) {
|
||||
con->request.http_method = con->request.error_handler_saved_method;
|
||||
}
|
||||
if (con->mode == DIRECT || con->conf.error_intercept) {
|
||||
if (con->error_handler_saved_status) {
|
||||
if (con->request.error_handler_saved_status) {
|
||||
const int subreq_status = con->http_status;
|
||||
if (con->error_handler_saved_status > 0) {
|
||||
con->http_status = con->error_handler_saved_status;
|
||||
if (con->request.error_handler_saved_status > 0) {
|
||||
con->http_status = con->request.error_handler_saved_status;
|
||||
} else if (con->http_status == 404 || con->http_status == 403) {
|
||||
/* error-handler-404 is a 404 */
|
||||
con->http_status = -con->error_handler_saved_status;
|
||||
con->http_status = -con->request.error_handler_saved_status;
|
||||
} else {
|
||||
/* error-handler-404 is back and has generated content */
|
||||
/* if Status: was set, take it otherwise use 200 */
|
||||
|
@ -1163,7 +1163,7 @@ static int connection_handle_request(connection *con) {
|
|||
if (200 <= subreq_status && subreq_status <= 299) {
|
||||
/*(flag value to indicate that error handler succeeded)
|
||||
*(for (con->mode == DIRECT))*/
|
||||
con->error_handler_saved_status = 65535; /* >= 1000 */
|
||||
con->request.error_handler_saved_status = 65535; /* >= 1000 */
|
||||
}
|
||||
} else if (con->http_status >= 400) {
|
||||
const buffer *error_handler = NULL;
|
||||
|
@ -1199,12 +1199,12 @@ static int connection_handle_request(connection *con) {
|
|||
con->response.resp_body_finished = 0;
|
||||
con->response.resp_body_started = 0;
|
||||
|
||||
con->error_handler_saved_status = con->http_status;
|
||||
con->error_handler_saved_method = con->request.http_method;
|
||||
con->request.error_handler_saved_status = con->http_status;
|
||||
con->request.error_handler_saved_method = con->request.http_method;
|
||||
|
||||
con->request.http_method = HTTP_METHOD_GET;
|
||||
} else { /*(preserve behavior for server.error-handler-404)*/
|
||||
con->error_handler_saved_status = -con->http_status; /*(negative to flag old behavior)*/
|
||||
con->request.error_handler_saved_status = -con->http_status; /*(negative to flag old behavior)*/
|
||||
}
|
||||
|
||||
if (con->request.http_version == HTTP_VERSION_UNSET) con->request.http_version = HTTP_VERSION_1_0;
|
||||
|
|
|
@ -1406,7 +1406,7 @@ int http_cgi_headers (connection *con, http_cgi_opts *opts, http_cgi_header_appe
|
|||
}
|
||||
/* set REDIRECT_STATUS for php compiled with --force-redirect
|
||||
* (if REDIRECT_STATUS has not already been set by error handler) */
|
||||
if (0 == con->error_handler_saved_status) {
|
||||
if (0 == con->request.error_handler_saved_status) {
|
||||
rc |= cb(vdata, CONST_STR_LEN("REDIRECT_STATUS"),
|
||||
CONST_STR_LEN("200"));
|
||||
}
|
||||
|
@ -1558,8 +1558,8 @@ int http_cgi_headers (connection *con, http_cgi_opts *opts, http_cgi_header_appe
|
|||
|
||||
con->srv->request_env(con);
|
||||
|
||||
for (n = 0; n < con->environment.used; n++) {
|
||||
data_string *ds = (data_string *)con->environment.data[n];
|
||||
for (n = 0; n < con->request.env.used; n++) {
|
||||
data_string *ds = (data_string *)con->request.env.data[n];
|
||||
if (!buffer_is_empty(&ds->value) && !buffer_is_empty(&ds->key)) {
|
||||
buffer_copy_string_encoded_cgi_varnames(tb,
|
||||
CONST_BUF_LEN(&ds->key), 0);
|
||||
|
|
|
@ -172,16 +172,16 @@ void http_header_request_append(connection *con, enum http_header_e id, const ch
|
|||
|
||||
|
||||
buffer * http_header_env_get(const connection *con, const char *k, size_t klen) {
|
||||
return http_header_generic_get_ifnotempty(&con->environment, k, klen);
|
||||
return http_header_generic_get_ifnotempty(&con->request.env, k, klen);
|
||||
}
|
||||
|
||||
void http_header_env_set(connection *con, const char *k, size_t klen, const char *v, size_t vlen) {
|
||||
array_set_key_value(&con->environment, k, klen, v, vlen);
|
||||
array_set_key_value(&con->request.env, k, klen, v, vlen);
|
||||
}
|
||||
|
||||
void http_header_env_append(connection *con, const char *k, size_t klen, const char *v, size_t vlen) {
|
||||
/*if (0 == vlen) return;*//* skip check; permit env var w/ blank value */
|
||||
buffer * const vb = array_get_buf_ptr(&con->environment, k, klen);
|
||||
buffer * const vb = array_get_buf_ptr(&con->request.env, k, klen);
|
||||
if (0 == vlen) return;
|
||||
http_header_token_append(vb, v, vlen);
|
||||
}
|
||||
|
|
|
@ -326,7 +326,7 @@ static handler_t mod_authn_gssapi_check_spnego(connection *con, plugin_data *p,
|
|||
{
|
||||
/* ??? Should code = krb5_kt_resolve(kcontext, p->conf.auth_gssapi_keytab->ptr, &keytab);
|
||||
* be used, instead of putenv() of KRB5_KTNAME=...? See mod_authn_gssapi_basic() */
|
||||
/* ??? Should KRB5_KTNAME go into con->environment instead ??? */
|
||||
/* ??? Should KRB5_KTNAME go into con->request.env instead ??? */
|
||||
/* ??? Should KRB5_KTNAME be added to mod_authn_gssapi_basic(), too? */
|
||||
buffer ktname;
|
||||
memset(&ktname, 0, sizeof(ktname));
|
||||
|
|
|
@ -617,7 +617,7 @@ static int magnet_cgi_set(lua_State *L) {
|
|||
static int magnet_cgi_pairs(lua_State *L) {
|
||||
connection *con = magnet_get_connection(L);
|
||||
|
||||
return magnet_array_pairs(L, &con->environment);
|
||||
return magnet_array_pairs(L, &con->request.env);
|
||||
}
|
||||
|
||||
|
||||
|
@ -988,14 +988,14 @@ static handler_t magnet_attract_array(connection *con, plugin_data *p, int is_ur
|
|||
ret = magnet_attract(con, p, &ds->value);
|
||||
}
|
||||
|
||||
if (con->error_handler_saved_status) {
|
||||
if (con->request.error_handler_saved_status) {
|
||||
/* retrieve (possibly modified) REDIRECT_STATUS and store as number */
|
||||
unsigned long x;
|
||||
const buffer * const vb = http_header_env_get(con, CONST_STR_LEN("REDIRECT_STATUS"));
|
||||
if (vb && (x = strtoul(vb->ptr, NULL, 10)) < 1000)
|
||||
/*(simplified validity check x < 1000)*/
|
||||
con->error_handler_saved_status =
|
||||
con->error_handler_saved_status > 0 ? (int)x : -(int)x;
|
||||
con->request.error_handler_saved_status =
|
||||
con->request.error_handler_saved_status > 0 ? (int)x : -(int)x;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -3576,7 +3576,7 @@ webdav_has_lock (connection * const con,
|
|||
/* XXX: maybe add config switch to require that authentication occurred? */
|
||||
buffer owner = { NULL, 0, 0 };/*owner (not authenticated)(auth_user unset)*/
|
||||
const data_string * const authn_user = (const data_string *)
|
||||
array_get_element_klen(&con->environment, CONST_STR_LEN("REMOTE_USER"));
|
||||
array_get_element_klen(&con->request.env, CONST_STR_LEN("REMOTE_USER"));
|
||||
cbdata.authn_user = authn_user ? &authn_user->value : &owner;
|
||||
|
||||
const buffer * const h =
|
||||
|
@ -5203,7 +5203,7 @@ mod_webdav_lock (connection * const con, const plugin_config * const pconf)
|
|||
/* XXX: maybe add config switch to require that authentication occurred? */
|
||||
buffer owner = { NULL, 0, 0 };/*owner (not authenticated)(auth_user unset)*/
|
||||
const data_string * const authn_user = (const data_string *)
|
||||
array_get_element_klen(&con->environment, CONST_STR_LEN("REMOTE_USER"));
|
||||
array_get_element_klen(&con->request.env, CONST_STR_LEN("REMOTE_USER"));
|
||||
|
||||
/* future: make max timeout configurable (e.g. pconf->lock_timeout_max)
|
||||
*
|
||||
|
@ -5498,7 +5498,7 @@ mod_webdav_unlock (connection * const con, const plugin_config * const pconf)
|
|||
|
||||
buffer owner = { NULL, 0, 0 };/*owner (not authenticated)(auth_user unset)*/
|
||||
const data_string * const authn_user = (const data_string *)
|
||||
array_get_element_klen(&con->environment, CONST_STR_LEN("REMOTE_USER"));
|
||||
array_get_element_klen(&con->request.env, CONST_STR_LEN("REMOTE_USER"));
|
||||
|
||||
webdav_lockdata lockdata = {
|
||||
{ h->ptr+1, h->used-2, 0 }, /* locktoken (remove < > around token) */
|
||||
|
|
|
@ -113,6 +113,13 @@ struct request_st {
|
|||
uint32_t conditional_is_valid;
|
||||
struct cond_cache_t *cond_cache;
|
||||
struct cond_match_t *cond_match;
|
||||
|
||||
array env; /* used to pass lighttpd internal stuff */
|
||||
|
||||
/* error-handler */
|
||||
int error_handler_saved_status;
|
||||
http_method_t error_handler_saved_method;
|
||||
|
||||
buffer *pathinfo;
|
||||
buffer *server_name_buf;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue