[core] store subrequest_handler instead of mode
store pointer to module in handler_module instead of con->mode id
This commit is contained in:
parent
eea7cd3c2f
commit
31d9495330
|
@ -15,8 +15,6 @@
|
|||
|
||||
struct fdevents; /* declaration */
|
||||
|
||||
#define DIRECT 0 /* con->mode */
|
||||
|
||||
|
||||
typedef struct {
|
||||
off_t content_length;
|
||||
|
@ -26,6 +24,7 @@ typedef struct {
|
|||
char resp_body_started;
|
||||
char resp_body_finished;
|
||||
uint32_t resp_header_len;
|
||||
plugin *handler_module;
|
||||
} response;
|
||||
|
||||
typedef struct {
|
||||
|
@ -89,8 +88,6 @@ struct connection {
|
|||
physical physical;
|
||||
response response;
|
||||
|
||||
int mode; /* DIRECT (0) or plugin id */
|
||||
|
||||
server *srv;
|
||||
|
||||
void *plugin_slots;
|
||||
|
|
|
@ -117,7 +117,7 @@ handler_t connection_handle_read_post_error(connection *con, int http_status) {
|
|||
|
||||
http_response_body_clear(con, 0);
|
||||
con->http_status = http_status;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -488,11 +488,11 @@ handler_t connection_handle_read_post_state(connection *con) {
|
|||
}
|
||||
|
||||
void connection_response_reset(connection *con) {
|
||||
con->mode = DIRECT;
|
||||
con->http_status = 0;
|
||||
con->is_writable = 1;
|
||||
con->response.resp_body_finished = 0;
|
||||
con->response.resp_body_started = 0;
|
||||
con->response.handler_module = NULL;
|
||||
if (con->physical.path) { /*(skip for mod_fastcgi authorizer)*/
|
||||
buffer_clear(con->physical.doc_root);
|
||||
buffer_reset(con->physical.path);
|
||||
|
|
|
@ -270,7 +270,7 @@ static void connection_handle_errdoc_init(connection *con) {
|
|||
|
||||
__attribute_cold__
|
||||
static void connection_handle_errdoc(connection *con) {
|
||||
if (con->mode == DIRECT
|
||||
if (NULL == con->response.handler_module
|
||||
? con->request.error_handler_saved_status >= 65535
|
||||
: (!con->conf.error_intercept||con->request.error_handler_saved_status))
|
||||
return;
|
||||
|
@ -325,7 +325,7 @@ static void connection_handle_errdoc(connection *con) {
|
|||
}
|
||||
|
||||
static int connection_handle_write_prepare(connection *con) {
|
||||
if (con->mode == DIRECT) {
|
||||
if (NULL == con->response.handler_module) {
|
||||
/* static files */
|
||||
switch(con->request.http_method) {
|
||||
case HTTP_METHOD_GET:
|
||||
|
@ -497,8 +497,9 @@ static void connection_handle_write_state(connection *con) {
|
|||
break;
|
||||
}
|
||||
|
||||
if (con->mode != DIRECT && !con->response.resp_body_finished) {
|
||||
int rc = plugins_call_handle_subrequest(con);
|
||||
if (con->response.handler_module && !con->response.resp_body_finished) {
|
||||
plugin * const p = con->response.handler_module;
|
||||
int rc = p->handle_subrequest(con, p->data);
|
||||
switch(rc) {
|
||||
case HANDLER_WAIT_FOR_EVENT:
|
||||
case HANDLER_FINISHED:
|
||||
|
@ -1148,7 +1149,7 @@ static int connection_handle_request(connection *con) {
|
|||
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 (NULL == con->response.handler_module || con->conf.error_intercept) {
|
||||
if (con->request.error_handler_saved_status) {
|
||||
const int subreq_status = con->http_status;
|
||||
if (con->request.error_handler_saved_status > 0) {
|
||||
|
@ -1162,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))*/
|
||||
*(for (NULL == con->response.handler_module))*/
|
||||
con->request.error_handler_saved_status = 65535; /* >= 1000 */
|
||||
}
|
||||
} else if (con->http_status >= 400) {
|
||||
|
@ -1225,7 +1226,7 @@ static int connection_handle_request(connection *con) {
|
|||
connection_fdwaitqueue_append(con);
|
||||
break;
|
||||
case HANDLER_COMEBACK:
|
||||
if (con->mode == DIRECT && buffer_is_empty(con->physical.path)) {
|
||||
if (NULL == con->response.handler_module && buffer_is_empty(con->physical.path)) {
|
||||
config_reset_config(con);
|
||||
}
|
||||
return 1;
|
||||
|
@ -1234,6 +1235,7 @@ static int connection_handle_request(connection *con) {
|
|||
connection_set_state(con, CON_STATE_ERROR);
|
||||
break;
|
||||
default:
|
||||
connection_set_state(con, CON_STATE_ERROR);
|
||||
log_error(con->conf.errh, __FILE__, __LINE__, "unknown ret-value: %d %d", con->fd, rc);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -931,7 +931,7 @@ static gw_host * gw_host_get(connection *con, gw_extension *extension, int balan
|
|||
/* all hosts are down */
|
||||
/* sorry, we don't have a server alive for this ext */
|
||||
con->http_status = 503; /* Service Unavailable */
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
|
||||
/* only send the 'no handler' once */
|
||||
if (!extension->note_is_sent) {
|
||||
|
@ -1758,7 +1758,7 @@ static void gw_connection_close(gw_handler_ctx *hctx, connection *con) {
|
|||
handler_ctx_free(hctx);
|
||||
con->request.plugin_ctx[p->id] = NULL;
|
||||
|
||||
if (con->mode == p->id) {
|
||||
if (con->response.handler_module == p->self) {
|
||||
http_response_backend_done(con);
|
||||
}
|
||||
}
|
||||
|
@ -2009,7 +2009,6 @@ handler_t gw_handle_subrequest(connection *con, void *p_d) {
|
|||
gw_plugin_data *p = p_d;
|
||||
gw_handler_ctx *hctx = con->request.plugin_ctx[p->id];
|
||||
if (NULL == hctx) return HANDLER_GO_ON;
|
||||
if (con->mode != p->id) return HANDLER_GO_ON; /* not my job */
|
||||
|
||||
if ((con->conf.stream_response_body & FDEVENT_STREAM_RESPONSE_BUFMIN)
|
||||
&& con->response.resp_body_started) {
|
||||
|
@ -2145,7 +2144,7 @@ static handler_t gw_recv_response(gw_handler_ctx *hctx, connection *con) {
|
|||
"too many loops while processing request: %s",
|
||||
con->request.target_orig->ptr);
|
||||
con->http_status = 500; /* Internal Server Error */
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -2159,7 +2158,7 @@ static handler_t gw_recv_response(gw_handler_ctx *hctx, connection *con) {
|
|||
/*(FYI: if multiple FastCGI authorizers were to be supported,
|
||||
* next one could be started here instead of restarting request)*/
|
||||
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_COMEBACK;
|
||||
} else {
|
||||
/* we are done */
|
||||
|
@ -2294,7 +2293,7 @@ static handler_t gw_handle_fdevent(void *ctx, int revents) {
|
|||
|
||||
handler_t gw_check_extension(connection *con, gw_plugin_data *p, int uri_path_handler, size_t hctx_sz) {
|
||||
#if 0 /*(caller must handle)*/
|
||||
if (con->mode != DIRECT) return HANDLER_GO_ON;
|
||||
if (NULL != con->response.handler_module) return HANDLER_GO_ON;
|
||||
gw_patch_connection(con, p);
|
||||
if (NULL == p->conf.exts) return HANDLER_GO_ON;
|
||||
#endif
|
||||
|
@ -2497,7 +2496,7 @@ handler_t gw_check_extension(connection *con, gw_plugin_data *p, int uri_path_ha
|
|||
|
||||
con->request.plugin_ctx[p->id] = hctx;
|
||||
|
||||
con->mode = p->id;
|
||||
con->response.handler_module = p->self;
|
||||
|
||||
if (con->conf.log_request_handling) {
|
||||
log_error(con->conf.errh, __FILE__, __LINE__, "handling it in mod_gw");
|
||||
|
|
|
@ -179,7 +179,7 @@ int http_response_handle_cachable(connection *con, const buffer *mtime) {
|
|||
return HANDLER_FINISHED;
|
||||
} else {
|
||||
con->http_status = 412;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
}
|
||||
|
@ -630,7 +630,7 @@ static void http_response_xsendfile (connection *con, buffer *path, const array
|
|||
"X-Sendfile invalid UTF-8 after url-decode: %s", path->ptr);
|
||||
if (con->http_status < 400) {
|
||||
con->http_status = 502;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -666,7 +666,7 @@ static void http_response_xsendfile (connection *con, buffer *path, const array
|
|||
if (valid) http_response_send_file(con, path);
|
||||
|
||||
if (con->http_status >= 400 && status < 300) {
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
} else if (0 != status && 200 != status) {
|
||||
con->http_status = status;
|
||||
}
|
||||
|
@ -805,7 +805,7 @@ range_success: ;
|
|||
}
|
||||
|
||||
if (con->http_status >= 400 && status < 300) {
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
} else if (0 != status && 200 != status) {
|
||||
con->http_status = status;
|
||||
}
|
||||
|
@ -816,7 +816,7 @@ void http_response_backend_error (connection *con) {
|
|||
if (con->response.resp_body_started) {
|
||||
/*(response might have been already started, kill the connection)*/
|
||||
/*(mode == DIRECT to avoid later call to http_response_backend_done())*/
|
||||
con->mode = DIRECT; /*(avoid sending final chunked block)*/
|
||||
con->response.handler_module = NULL; /*(avoid sending final chunked block)*/
|
||||
con->request.keep_alive = 0;
|
||||
con->response.resp_body_finished = 1;
|
||||
} /*(else error status set later by http_response_backend_done())*/
|
||||
|
@ -832,7 +832,7 @@ void http_response_backend_done (connection *con) {
|
|||
if (!con->response.resp_body_started) {
|
||||
/* Send an error if we haven't sent any data yet */
|
||||
con->http_status = 500;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
break;
|
||||
} /* else fall through */
|
||||
case CON_STATE_WRITE:
|
||||
|
@ -901,7 +901,7 @@ static handler_t http_response_process_local_redir(connection *con, size_t blen)
|
|||
"too many internal loops while processing request: %s",
|
||||
con->request.target_orig->ptr);
|
||||
con->http_status = 500; /* Internal Server Error */
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -964,7 +964,7 @@ static int http_response_process_headers(connection *con, http_response_opts *op
|
|||
log_error(con->conf.errh, __FILE__, __LINE__,
|
||||
"invalid HTTP status line: %s", s);
|
||||
con->http_status = 502; /* Bad Gateway */
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1014,7 +1014,7 @@ static int http_response_process_headers(connection *con, http_response_opts *op
|
|||
status_is_set = 1;
|
||||
} else {
|
||||
con->http_status = 502;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
}
|
||||
continue; /* do not send Status to client */
|
||||
}
|
||||
|
@ -1043,7 +1043,7 @@ static int http_response_process_headers(connection *con, http_response_opts *op
|
|||
"proxy backend sent invalid response header "
|
||||
"(Transfer-Encoding) to HTTP/1.0 request");
|
||||
con->http_status = 502; /* Bad Gateway */
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
@ -1127,7 +1127,7 @@ handler_t http_response_parse_headers(connection *con, http_response_opts *opts,
|
|||
} else {
|
||||
/* invalid response headers */
|
||||
con->http_status = 502; /* Bad Gateway */
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -1138,7 +1138,7 @@ handler_t http_response_parse_headers(connection *con, http_response_opts *opts,
|
|||
log_error(con->conf.errh, __FILE__, __LINE__,
|
||||
"response headers too large for %s", con->uri.path->ptr);
|
||||
con->http_status = 502; /* Bad Gateway */
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
return HANDLER_GO_ON;
|
||||
|
@ -1158,7 +1158,7 @@ handler_t http_response_parse_headers(connection *con, http_response_opts *opts,
|
|||
if (opts->backend == BACKEND_PROXY && !is_nph) {
|
||||
/* invalid response Status-Line from HTTP proxy */
|
||||
con->http_status = 502; /* Bad Gateway */
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -1173,14 +1173,15 @@ handler_t http_response_parse_headers(connection *con, http_response_opts *opts,
|
|||
return HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
if (con->mode == DIRECT) {
|
||||
if (NULL == con->response.handler_module) {
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
||||
if (opts->local_redir && con->http_status >= 300 && con->http_status < 400){
|
||||
/*(con->response.htags & HTTP_HEADER_LOCATION)*/
|
||||
handler_t rc = http_response_process_local_redir(con, blen);
|
||||
if (con->mode == DIRECT) con->response.resp_body_started = 0;
|
||||
if (NULL == con->response.handler_module)
|
||||
con->response.resp_body_started = 0;
|
||||
if (rc != HANDLER_GO_ON) return rc;
|
||||
}
|
||||
|
||||
|
@ -1192,7 +1193,8 @@ handler_t http_response_parse_headers(connection *con, http_response_opts *opts,
|
|||
http_response_xsendfile2(con, vb, opts->xsendfile_docroot);
|
||||
/* http_header_response_unset() shortcut for HTTP_HEADER_OTHER */
|
||||
buffer_clear(vb); /*(do not send to client)*/
|
||||
if (con->mode == DIRECT) con->response.resp_body_started = 0;
|
||||
if (NULL == con->response.handler_module)
|
||||
con->response.resp_body_started = 0;
|
||||
return HANDLER_FINISHED;
|
||||
} else if (NULL != (vb = http_header_response_get(con, HTTP_HEADER_OTHER, CONST_STR_LEN("X-Sendfile")))
|
||||
|| (opts->backend == BACKEND_FASTCGI /* X-LIGHTTPD-send-file is deprecated; historical for fastcgi */
|
||||
|
@ -1200,7 +1202,8 @@ handler_t http_response_parse_headers(connection *con, http_response_opts *opts,
|
|||
http_response_xsendfile(con, vb, opts->xsendfile_docroot);
|
||||
/* http_header_response_unset() shortcut for HTTP_HEADER_OTHER */
|
||||
buffer_clear(vb); /*(do not send to client)*/
|
||||
if (con->mode == DIRECT) con->response.resp_body_started = 0;
|
||||
if (NULL == con->response.handler_module)
|
||||
con->response.resp_body_started = 0;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ static handler_t mod_access_reject (connection * const con, plugin_data * const
|
|||
}
|
||||
|
||||
con->http_status = 403;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
||||
|
|
|
@ -517,14 +517,14 @@ static handler_t mod_auth_send_400_bad_request(connection *con) {
|
|||
|
||||
/* a field was missing or invalid */
|
||||
con->http_status = 400; /* Bad Request */
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
||||
static handler_t mod_auth_send_401_unauthorized_basic(connection *con, const buffer *realm) {
|
||||
con->http_status = 401;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
|
||||
buffer * const tb = con->srv->tmp_buf;
|
||||
buffer_copy_string_len(tb, CONST_STR_LEN("Basic realm=\""));
|
||||
|
@ -547,7 +547,7 @@ static handler_t mod_auth_check_basic(connection *con, void *p_d, const struct h
|
|||
if (NULL == backend) {
|
||||
log_error(con->conf.errh, __FILE__, __LINE__, "auth.backend not configured for %s", con->uri.path->ptr);
|
||||
con->http_status = 500;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -972,7 +972,7 @@ static handler_t mod_auth_check_digest(connection *con, void *p_d, const struct
|
|||
log_error(con->conf.errh, __FILE__, __LINE__,
|
||||
"auth.backend not configured for %s", con->uri.path->ptr);
|
||||
con->http_status = 500;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -1194,7 +1194,7 @@ static handler_t mod_auth_send_401_unauthorized_digest(connection *con, const st
|
|||
http_header_response_set(con, HTTP_HEADER_OTHER, CONST_STR_LEN("WWW-Authenticate"), CONST_BUF_LEN(tb));
|
||||
|
||||
con->http_status = 401;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -1207,7 +1207,7 @@ static handler_t mod_auth_check_extern(connection *con, void *p_d, const struct
|
|||
return HANDLER_GO_ON;
|
||||
} else {
|
||||
con->http_status = 401;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ __attribute_cold__
|
|||
static handler_t mod_authn_gssapi_send_400_bad_request (connection *con)
|
||||
{
|
||||
con->http_status = 400;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -243,14 +243,14 @@ static int mod_authn_gssapi_create_krb5_ccache(connection *con, plugin_data *p,
|
|||
static handler_t mod_authn_gssapi_send_500_server_error (connection *con)
|
||||
{
|
||||
con->http_status = 500;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
||||
static handler_t mod_authn_gssapi_send_401_unauthorized_negotiate (connection *con)
|
||||
{
|
||||
con->http_status = 401;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
http_header_response_set(con, HTTP_HEADER_OTHER, CONST_STR_LEN("WWW-Authenticate"), CONST_STR_LEN("Negotiate"));
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
@ -600,7 +600,7 @@ static int mod_authn_gssapi_store_krb5_creds(connection *con, plugin_data *p,
|
|||
static handler_t mod_authn_gssapi_send_401_unauthorized_basic (connection *con)
|
||||
{
|
||||
con->http_status = 401;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
http_header_response_set(con, HTTP_HEADER_OTHER, CONST_STR_LEN("WWW-Authenticate"), CONST_STR_LEN("Basic realm=\"Kerberos\""));
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
|
|
@ -334,7 +334,7 @@ static void cgi_connection_close(connection *con, handler_ctx *hctx) {
|
|||
cgi_handler_ctx_free(hctx);
|
||||
|
||||
/* finish response (if not already con->response.resp_body_started, con->response.resp_body_finished) */
|
||||
if (con->mode == p->id) {
|
||||
if (con->response.handler_module == p->self) {
|
||||
http_response_backend_done(con);
|
||||
}
|
||||
}
|
||||
|
@ -881,7 +881,7 @@ URIHANDLER_FUNC(cgi_is_handled) {
|
|||
const struct stat *st;
|
||||
data_string *ds;
|
||||
|
||||
if (con->mode != DIRECT) return HANDLER_GO_ON;
|
||||
if (NULL != con->response.handler_module) return HANDLER_GO_ON;
|
||||
if (buffer_is_empty(con->physical.path)) return HANDLER_GO_ON;
|
||||
|
||||
mod_cgi_patch_config(con, p);
|
||||
|
@ -915,7 +915,7 @@ URIHANDLER_FUNC(cgi_is_handled) {
|
|||
hctx->opts.pdata = hctx;
|
||||
hctx->opts.headers = cgi_response_headers;
|
||||
con->request.plugin_ctx[p->id] = hctx;
|
||||
con->mode = p->id;
|
||||
con->response.handler_module = p->self;
|
||||
}
|
||||
|
||||
return HANDLER_GO_ON;
|
||||
|
@ -929,8 +929,6 @@ URIHANDLER_FUNC(cgi_is_handled) {
|
|||
SUBREQUEST_FUNC(mod_cgi_handle_subrequest) {
|
||||
plugin_data * const p = p_d;
|
||||
handler_ctx * const hctx = con->request.plugin_ctx[p->id];
|
||||
|
||||
if (con->mode != p->id) return HANDLER_GO_ON;
|
||||
if (NULL == hctx) return HANDLER_GO_ON;
|
||||
|
||||
if ((con->conf.stream_response_body & FDEVENT_STREAM_RESPONSE_BUFMIN)
|
||||
|
@ -976,7 +974,7 @@ SUBREQUEST_FUNC(mod_cgi_handle_subrequest) {
|
|||
if (-1 == hctx->fd) {
|
||||
if (cgi_create_env(con, p, hctx, hctx->cgi_handler)) {
|
||||
con->http_status = 500;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
|
|
@ -783,7 +783,7 @@ PHYSICALPATH_FUNC(mod_compress_physical) {
|
|||
buffer *content_type_trunc;
|
||||
const buffer *content_type;
|
||||
|
||||
if (con->mode != DIRECT || con->http_status) return HANDLER_GO_ON;
|
||||
if (NULL != con->response.handler_module || con->http_status) return HANDLER_GO_ON;
|
||||
|
||||
/* only GET and POST can get compressed */
|
||||
if (con->request.http_method != HTTP_METHOD_GET &&
|
||||
|
|
|
@ -1165,12 +1165,12 @@ CONNECTION_FUNC(mod_deflate_handle_response_start) {
|
|||
* For now, send back empty response body.
|
||||
* In the future, might extract the error doc code so that it
|
||||
* might be run again if response_start hooks return with
|
||||
* changed http_status and con->mode = DIRECT */
|
||||
* changed http_status and con->response.handler_module = NULL */
|
||||
/* clear content length even if 304 since compressed length unknown */
|
||||
http_response_body_clear(con, 0);
|
||||
|
||||
con->response.resp_body_finished = 1;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_GO_ON;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1026,7 +1026,7 @@ URIHANDLER_FUNC(mod_dirlisting_subrequest) {
|
|||
plugin_data *p = p_d;
|
||||
stat_cache_entry *sce = NULL;
|
||||
|
||||
if (con->mode != DIRECT) return HANDLER_GO_ON;
|
||||
if (NULL != con->response.handler_module) return HANDLER_GO_ON;
|
||||
if (buffer_is_empty(con->uri.path)) return HANDLER_GO_ON;
|
||||
if (con->uri.path->ptr[buffer_string_length(con->uri.path) - 1] != '/') return HANDLER_GO_ON;
|
||||
if (!http_method_get_or_head(con->request.http_method)) return HANDLER_GO_ON;
|
||||
|
|
|
@ -136,7 +136,7 @@ URIHANDLER_FUNC(mod_evasive_uri_handler) {
|
|||
} else {
|
||||
con->http_status = 403;
|
||||
}
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -711,7 +711,7 @@ static handler_t mod_extforward_Forwarded (connection *con, plugin_data *p, cons
|
|||
log_error(con->conf.errh, __FILE__, __LINE__,
|
||||
"invalid quoted-string in Forwarded header");
|
||||
con->http_status = 400; /* Bad Request */
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
if (s[i] != '=') continue;
|
||||
|
@ -723,7 +723,7 @@ static handler_t mod_extforward_Forwarded (connection *con, plugin_data *p, cons
|
|||
log_error(con->conf.errh, __FILE__, __LINE__,
|
||||
"invalid quoted-string in Forwarded header");
|
||||
con->http_status = 400; /* Bad Request */
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
vlen = i - v; /* might be 0 */
|
||||
|
@ -746,7 +746,7 @@ static handler_t mod_extforward_Forwarded (connection *con, plugin_data *p, cons
|
|||
log_error(con->conf.errh, __FILE__, __LINE__,
|
||||
"Too many params in Forwarded header");
|
||||
con->http_status = 400; /* Bad Request */
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -781,7 +781,7 @@ static handler_t mod_extforward_Forwarded (connection *con, plugin_data *p, cons
|
|||
log_error(con->conf.errh, __FILE__, __LINE__,
|
||||
"Invalid IPv6 addr in Forwarded header");
|
||||
con->http_status = 400; /* Bad Request */
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
}
|
||||
|
@ -922,7 +922,7 @@ static handler_t mod_extforward_Forwarded (connection *con, plugin_data *p, cons
|
|||
log_error(con->conf.errh, __FILE__, __LINE__,
|
||||
"invalid host= value in Forwarded header");
|
||||
con->http_status = 400; /* Bad Request */
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
}
|
||||
|
@ -939,7 +939,7 @@ static handler_t mod_extforward_Forwarded (connection *con, plugin_data *p, cons
|
|||
log_error(con->conf.errh, __FILE__, __LINE__,
|
||||
"invalid host= value in Forwarded header");
|
||||
con->http_status = 400; /* Bad Request */
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -974,7 +974,7 @@ static handler_t mod_extforward_Forwarded (connection *con, plugin_data *p, cons
|
|||
log_error(con->conf.errh, __FILE__, __LINE__,
|
||||
"invalid remote_user= value in Forwarded header");
|
||||
con->http_status = 400; /* Bad Request */
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -300,7 +300,7 @@ static handler_t fcgi_create_env(handler_ctx *hctx) {
|
|||
|
||||
if (0 != http_cgi_headers(con, &opts, fcgi_env_add, b)) {
|
||||
con->http_status = 400;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
buffer_clear(b);
|
||||
chunkqueue_remove_finished_chunks(hctx->wb);
|
||||
return HANDLER_FINISHED;
|
||||
|
@ -495,7 +495,7 @@ static handler_t fcgi_check_extension(connection *con, void *p_d, int uri_path_h
|
|||
plugin_data *p = p_d;
|
||||
handler_t rc;
|
||||
|
||||
if (con->mode != DIRECT) return HANDLER_GO_ON;
|
||||
if (NULL != con->response.handler_module) return HANDLER_GO_ON;
|
||||
|
||||
mod_fastcgi_patch_config(con, p);
|
||||
if (NULL == p->conf.exts) return HANDLER_GO_ON;
|
||||
|
@ -503,7 +503,7 @@ static handler_t fcgi_check_extension(connection *con, void *p_d, int uri_path_h
|
|||
rc = gw_check_extension(con, p, uri_path_handler, 0);
|
||||
if (HANDLER_GO_ON != rc) return rc;
|
||||
|
||||
if (con->mode == p->id) {
|
||||
if (con->response.handler_module == p->self) {
|
||||
handler_ctx *hctx = con->request.plugin_ctx[p->id];
|
||||
hctx->opts.backend = BACKEND_FASTCGI;
|
||||
hctx->opts.parse = fcgi_recv_parse;
|
||||
|
|
|
@ -94,7 +94,7 @@ static off_t get_param_value(buffer *qb, const char *m, size_t mlen) {
|
|||
URIHANDLER_FUNC(mod_flv_streaming_path_handler) {
|
||||
plugin_data *p = p_d;
|
||||
|
||||
if (con->mode != DIRECT) return HANDLER_GO_ON;
|
||||
if (NULL != con->response.handler_module) return HANDLER_GO_ON;
|
||||
if (buffer_string_is_empty(con->physical.path)) return HANDLER_GO_ON;
|
||||
|
||||
mod_flv_streaming_patch_config(con, p);
|
||||
|
|
|
@ -85,7 +85,7 @@ SETDEFAULTS_FUNC(mod_indexfile_set_defaults) {
|
|||
URIHANDLER_FUNC(mod_indexfile_subrequest) {
|
||||
plugin_data *p = p_d;
|
||||
|
||||
if (con->mode != DIRECT) return HANDLER_GO_ON;
|
||||
if (NULL != con->response.handler_module) return HANDLER_GO_ON;
|
||||
|
||||
if (buffer_is_empty(con->uri.path)) return HANDLER_GO_ON;
|
||||
if (con->uri.path->ptr[buffer_string_length(con->uri.path) - 1] != '/') return HANDLER_GO_ON;
|
||||
|
|
|
@ -772,7 +772,7 @@ static handler_t magnet_attract(connection *con, plugin_data *p, buffer *name) {
|
|||
force_assert(lua_gettop(L) == 0); /* only the error should have been on the stack */
|
||||
|
||||
con->http_status = 500;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
@ -910,7 +910,7 @@ static handler_t magnet_attract(connection *con, plugin_data *p, buffer *name) {
|
|||
force_assert(lua_gettop(L) == 1); /* only the function should be on the stack */
|
||||
|
||||
con->http_status = 500;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
@ -946,13 +946,13 @@ static handler_t magnet_attract(connection *con, plugin_data *p, buffer *name) {
|
|||
if (0 == setjmp(exceptionjmp)) {
|
||||
magnet_attach_content(con, L, lighty_table_ndx);
|
||||
if (!chunkqueue_is_empty(con->write_queue)) {
|
||||
con->mode = p->id;
|
||||
con->response.handler_module = p->self;
|
||||
}
|
||||
} else {
|
||||
lua_settop(L, 2); /* remove all but function and lighty table */
|
||||
/* } catch () { */
|
||||
con->http_status = 500;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
}
|
||||
|
||||
result = HANDLER_FINISHED;
|
||||
|
|
|
@ -357,7 +357,7 @@ ERR500:
|
|||
while (mysql_next_result(p->conf.mysql) == 0);
|
||||
#endif
|
||||
con->http_status = 500; /* Internal Error */
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
||||
|
|
|
@ -1022,7 +1022,7 @@ static handler_t mod_proxy_check_extension(connection *con, void *p_d) {
|
|||
plugin_data *p = p_d;
|
||||
handler_t rc;
|
||||
|
||||
if (con->mode != DIRECT) return HANDLER_GO_ON;
|
||||
if (NULL != con->response.handler_module) return HANDLER_GO_ON;
|
||||
|
||||
mod_proxy_patch_config(con, p);
|
||||
if (NULL == p->conf.gw.exts) return HANDLER_GO_ON;
|
||||
|
@ -1030,7 +1030,7 @@ static handler_t mod_proxy_check_extension(connection *con, void *p_d) {
|
|||
rc = gw_check_extension(con, (gw_plugin_data *)p, 1, sizeof(handler_ctx));
|
||||
if (HANDLER_GO_ON != rc) return rc;
|
||||
|
||||
if (con->mode == p->id) {
|
||||
if (con->response.handler_module == p->self) {
|
||||
handler_ctx *hctx = con->request.plugin_ctx[p->id];
|
||||
hctx->gw.create_env = proxy_create_env;
|
||||
hctx->gw.response = chunk_buffer_acquire();
|
||||
|
@ -1058,7 +1058,7 @@ static handler_t mod_proxy_check_extension(connection *con, void *p_d) {
|
|||
}
|
||||
else {
|
||||
con->http_status = 405; /* Method Not Allowed */
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ URIHANDLER_FUNC(mod_redirect_uri_handler) {
|
|||
CONST_STR_LEN("Location"),
|
||||
CONST_BUF_LEN(tb));
|
||||
con->http_status = p->conf.redirect_code;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
con->response.resp_body_finished = 1;
|
||||
}
|
||||
else if (HANDLER_ERROR == rc) {
|
||||
|
|
|
@ -316,7 +316,7 @@ static handler_t process_rewrite_rules(connection *con, plugin_data *p, const pc
|
|||
URIHANDLER_FUNC(mod_rewrite_physical) {
|
||||
plugin_data * const p = p_d;
|
||||
|
||||
if (con->mode != DIRECT) return HANDLER_GO_ON;
|
||||
if (NULL != con->response.handler_module) return HANDLER_GO_ON;
|
||||
|
||||
mod_rewrite_patch_config(con, p);
|
||||
if (!p->conf.rewrite_NF || !p->conf.rewrite_NF->used) return HANDLER_GO_ON;
|
||||
|
|
|
@ -224,7 +224,7 @@ static handler_t scgi_create_env(handler_ctx *hctx) {
|
|||
|
||||
if (0 != http_cgi_headers(con, &opts, scgi_env_add, b)) {
|
||||
con->http_status = 400;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
buffer_clear(b);
|
||||
chunkqueue_remove_finished_chunks(hctx->wb);
|
||||
return HANDLER_FINISHED;
|
||||
|
@ -247,7 +247,7 @@ static handler_t scgi_create_env(handler_ctx *hctx) {
|
|||
uint32_t uwsgi_header;
|
||||
if (len > USHRT_MAX) {
|
||||
con->http_status = 431; /* Request Header Fields Too Large */
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
buffer_clear(b);
|
||||
chunkqueue_remove_finished_chunks(hctx->wb);
|
||||
return HANDLER_FINISHED;
|
||||
|
@ -283,7 +283,7 @@ static handler_t scgi_check_extension(connection *con, void *p_d, int uri_path_h
|
|||
plugin_data *p = p_d;
|
||||
handler_t rc;
|
||||
|
||||
if (con->mode != DIRECT) return HANDLER_GO_ON;
|
||||
if (NULL != con->response.handler_module) return HANDLER_GO_ON;
|
||||
|
||||
mod_scgi_patch_config(con, p);
|
||||
if (NULL == p->conf.exts) return HANDLER_GO_ON;
|
||||
|
@ -291,7 +291,7 @@ static handler_t scgi_check_extension(connection *con, void *p_d, int uri_path_h
|
|||
rc = gw_check_extension(con, p, uri_path_handler, 0);
|
||||
if (HANDLER_GO_ON != rc) return rc;
|
||||
|
||||
if (con->mode == p->id) {
|
||||
if (con->response.handler_module == p->self) {
|
||||
handler_ctx *hctx = con->request.plugin_ctx[p->id];
|
||||
hctx->opts.backend = BACKEND_SCGI;
|
||||
hctx->create_env = scgi_create_env;
|
||||
|
|
|
@ -422,7 +422,7 @@ URIHANDLER_FUNC(mod_secdownload_uri_handler) {
|
|||
time_t ts = 0;
|
||||
size_t i, mac_len;
|
||||
|
||||
if (con->mode != DIRECT) return HANDLER_GO_ON;
|
||||
if (NULL != con->response.handler_module) return HANDLER_GO_ON;
|
||||
|
||||
if (buffer_is_empty(con->uri.path)) return HANDLER_GO_ON;
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ URIHANDLER_FUNC(mod_skeleton_uri_handler) {
|
|||
|
||||
/* determine whether or not module participates in request */
|
||||
|
||||
if (con->mode != DIRECT) return HANDLER_GO_ON;
|
||||
if (NULL != con->response.handler_module) return HANDLER_GO_ON;
|
||||
if (buffer_string_is_empty(con->uri.path)) return HANDLER_GO_ON;
|
||||
|
||||
/* get module config for request */
|
||||
|
|
|
@ -139,7 +139,7 @@ static handler_t mod_sockproxy_connection_accept(connection *con, void *p_d) {
|
|||
plugin_data *p = p_d;
|
||||
handler_t rc;
|
||||
|
||||
if (con->mode != DIRECT) return HANDLER_GO_ON;
|
||||
if (NULL != con->response.handler_module) return HANDLER_GO_ON;
|
||||
|
||||
mod_sockproxy_patch_config(con, p);
|
||||
if (NULL == p->conf.exts) return HANDLER_GO_ON;
|
||||
|
@ -150,7 +150,7 @@ static handler_t mod_sockproxy_connection_accept(connection *con, void *p_d) {
|
|||
rc = gw_check_extension(con, p, 1, 0);
|
||||
if (HANDLER_GO_ON != rc) return rc;
|
||||
|
||||
if (con->mode == p->id) {
|
||||
if (con->response.handler_module == p->self) {
|
||||
handler_ctx *hctx = con->request.plugin_ctx[p->id];
|
||||
hctx->opts.backend = BACKEND_PROXY;
|
||||
hctx->create_env = sockproxy_create_env_connect;
|
||||
|
|
|
@ -1247,7 +1247,7 @@ static int mod_ssi_handle_request(connection *con, handler_ctx *p) {
|
|||
URIHANDLER_FUNC(mod_ssi_physical_path) {
|
||||
plugin_data *p = p_d;
|
||||
|
||||
if (con->mode != DIRECT) return HANDLER_GO_ON;
|
||||
if (NULL != con->response.handler_module) return HANDLER_GO_ON;
|
||||
if (buffer_is_empty(con->physical.path)) return HANDLER_GO_ON;
|
||||
|
||||
mod_ssi_patch_config(con, p);
|
||||
|
@ -1255,7 +1255,7 @@ URIHANDLER_FUNC(mod_ssi_physical_path) {
|
|||
|
||||
if (array_match_value_suffix(p->conf.ssi_extension, con->physical.path)) {
|
||||
con->request.plugin_ctx[p->id] = handler_ctx_init(p, con->conf.errh);
|
||||
con->mode = p->id;
|
||||
con->response.handler_module = p->self;
|
||||
}
|
||||
|
||||
return HANDLER_GO_ON;
|
||||
|
@ -1265,7 +1265,6 @@ SUBREQUEST_FUNC(mod_ssi_handle_subrequest) {
|
|||
plugin_data *p = p_d;
|
||||
handler_ctx *hctx = con->request.plugin_ctx[p->id];
|
||||
if (NULL == hctx) return HANDLER_GO_ON;
|
||||
if (con->mode != p->id) return HANDLER_GO_ON; /* not my job */
|
||||
/*
|
||||
* NOTE: if mod_ssi modified to use fdevents, HANDLER_WAIT_FOR_EVENT,
|
||||
* instead of blocking to completion, then hctx->timefmt, hctx->ssi_vars,
|
||||
|
@ -1277,7 +1276,7 @@ SUBREQUEST_FUNC(mod_ssi_handle_subrequest) {
|
|||
if (mod_ssi_handle_request(con, hctx)) {
|
||||
/* on error */
|
||||
con->http_status = 500;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
}
|
||||
|
||||
return HANDLER_FINISHED;
|
||||
|
|
|
@ -103,7 +103,7 @@ URIHANDLER_FUNC(mod_staticfile_subrequest) {
|
|||
if (buffer_is_empty(con->physical.path)) return HANDLER_GO_ON;
|
||||
|
||||
/* someone else has handled this request */
|
||||
if (con->mode != DIRECT) return HANDLER_GO_ON;
|
||||
if (NULL != con->response.handler_module) return HANDLER_GO_ON;
|
||||
|
||||
/* we only handle GET, POST and HEAD */
|
||||
if (!http_method_get_head_post(con->request.http_method)) return HANDLER_GO_ON;
|
||||
|
|
|
@ -818,7 +818,7 @@ static handler_t mod_status_handle_server_config(connection *con) {
|
|||
static handler_t mod_status_handler(connection *con, void *p_d) {
|
||||
plugin_data *p = p_d;
|
||||
|
||||
if (con->mode != DIRECT) return HANDLER_GO_ON;
|
||||
if (NULL != con->response.handler_module) return HANDLER_GO_ON;
|
||||
|
||||
mod_status_patch_config(con, p);
|
||||
|
||||
|
|
|
@ -356,7 +356,7 @@ URIHANDLER_FUNC(mod_trigger_b4_dl_uri_handler) {
|
|||
# define N 10
|
||||
int ovec[N * 3];
|
||||
|
||||
if (con->mode != DIRECT) return HANDLER_GO_ON;
|
||||
if (NULL != con->response.handler_module) return HANDLER_GO_ON;
|
||||
|
||||
if (buffer_is_empty(con->uri.path)) return HANDLER_GO_ON;
|
||||
|
||||
|
|
|
@ -264,7 +264,7 @@ URIHANDLER_FUNC(mod_uploadprogress_uri_handler) {
|
|||
con->response.resp_body_finished = 1;
|
||||
|
||||
con->http_status = 200;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
|
||||
/* get the connection */
|
||||
if (NULL == (post_con = connection_map_get_connection(&p->con_map, id, len))) {
|
||||
|
|
|
@ -142,7 +142,7 @@ CONNECTION_FUNC(mod_vhostdb_handle_connection_close) {
|
|||
static handler_t mod_vhostdb_error_500 (connection *con)
|
||||
{
|
||||
con->http_status = 500; /* Internal Server Error */
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
||||
|
|
|
@ -212,7 +212,7 @@
|
|||
|
||||
#define http_status_get(con) ((con)->http_status)
|
||||
#define http_status_set_fin(con, code) ((con)->response.resp_body_finished = 1,\
|
||||
(con)->mode = DIRECT, \
|
||||
(con)->response.handler_module = NULL, \
|
||||
(con)->http_status = (code))
|
||||
#define http_status_set(con, code) ((con)->http_status = (code))
|
||||
#define http_status_unset(con) ((con)->http_status = 0)
|
||||
|
@ -5639,7 +5639,7 @@ PHYSICALPATH_FUNC(mod_webdav_physical_handler)
|
|||
break;
|
||||
}
|
||||
|
||||
con->mode = ((plugin_data *)p_d)->id;
|
||||
con->response.handler_module = ((plugin_data *)p_d)->self;
|
||||
con->conf.stream_request_body = 0;
|
||||
con->request.plugin_ctx[((plugin_data *)p_d)->id] = &pconf;
|
||||
const handler_t rc =
|
||||
|
|
|
@ -558,7 +558,7 @@ static handler_t mod_wstunnel_check_extension(connection *con, void *p_d) {
|
|||
const buffer *vb;
|
||||
handler_t rc;
|
||||
|
||||
if (con->mode != DIRECT)
|
||||
if (NULL != con->response.handler_module)
|
||||
return HANDLER_GO_ON;
|
||||
if (con->request.http_method != HTTP_METHOD_GET)
|
||||
return HANDLER_GO_ON;
|
||||
|
@ -582,7 +582,7 @@ static handler_t mod_wstunnel_check_extension(connection *con, void *p_d) {
|
|||
if (NULL == p->conf.gw.exts) return HANDLER_GO_ON;
|
||||
|
||||
rc = gw_check_extension(con, (gw_plugin_data *)p, 1, sizeof(handler_ctx));
|
||||
return (HANDLER_GO_ON == rc && con->mode == p->id)
|
||||
return (HANDLER_GO_ON == rc && con->response.handler_module == p->self)
|
||||
? wstunnel_handler_setup(con, p)
|
||||
: rc;
|
||||
}
|
||||
|
@ -596,7 +596,7 @@ TRIGGER_FUNC(mod_wstunnel_handle_trigger) {
|
|||
for (uint32_t i = 0; i < srv->conns.used; ++i) {
|
||||
connection *con = srv->conns.ptr[i];
|
||||
handler_ctx *hctx = con->request.plugin_ctx[p->id];
|
||||
if (NULL == hctx || con->mode != p->id)
|
||||
if (NULL == hctx || con->response.handler_module != p->self)
|
||||
continue;
|
||||
|
||||
if (hctx->gw.state != GW_STATE_WRITE && hctx->gw.state != GW_STATE_READ)
|
||||
|
|
|
@ -38,7 +38,7 @@ typedef enum {
|
|||
PLUGIN_FUNC_HANDLE_TRIGGER,
|
||||
PLUGIN_FUNC_HANDLE_SIGHUP,
|
||||
PLUGIN_FUNC_HANDLE_WAITPID,
|
||||
PLUGIN_FUNC_HANDLE_SUBREQUEST,
|
||||
/* PLUGIN_FUNC_HANDLE_SUBREQUEST, *//* max one handler_module per req */
|
||||
PLUGIN_FUNC_HANDLE_SUBREQUEST_START,
|
||||
PLUGIN_FUNC_HANDLE_RESPONSE_START,
|
||||
PLUGIN_FUNC_HANDLE_DOCROOT,
|
||||
|
@ -339,7 +339,6 @@ PLUGIN_CALL_FN_CON_DATA(PLUGIN_FUNC_HANDLE_REQUEST_DONE, handle_request_done)
|
|||
PLUGIN_CALL_FN_CON_DATA(PLUGIN_FUNC_HANDLE_CONNECTION_ACCEPT, handle_connection_accept)
|
||||
PLUGIN_CALL_FN_CON_DATA(PLUGIN_FUNC_HANDLE_CONNECTION_SHUT_WR, handle_connection_shut_wr)
|
||||
PLUGIN_CALL_FN_CON_DATA(PLUGIN_FUNC_HANDLE_CONNECTION_CLOSE, handle_connection_close)
|
||||
PLUGIN_CALL_FN_CON_DATA(PLUGIN_FUNC_HANDLE_SUBREQUEST, handle_subrequest)
|
||||
PLUGIN_CALL_FN_CON_DATA(PLUGIN_FUNC_HANDLE_SUBREQUEST_START, handle_subrequest_start)
|
||||
PLUGIN_CALL_FN_CON_DATA(PLUGIN_FUNC_HANDLE_RESPONSE_START, handle_response_start)
|
||||
PLUGIN_CALL_FN_CON_DATA(PLUGIN_FUNC_HANDLE_DOCROOT, handle_docroot)
|
||||
|
@ -469,8 +468,6 @@ handler_t plugins_call_init(server *srv) {
|
|||
++offsets[PLUGIN_FUNC_HANDLE_SIGHUP];
|
||||
if (p->handle_waitpid)
|
||||
++offsets[PLUGIN_FUNC_HANDLE_WAITPID];
|
||||
if (p->handle_subrequest)
|
||||
++offsets[PLUGIN_FUNC_HANDLE_SUBREQUEST];
|
||||
if (p->handle_subrequest_start)
|
||||
++offsets[PLUGIN_FUNC_HANDLE_SUBREQUEST_START];
|
||||
if (p->handle_response_start)
|
||||
|
@ -526,8 +523,6 @@ handler_t plugins_call_init(server *srv) {
|
|||
offsets[PLUGIN_FUNC_HANDLE_SIGHUP]);
|
||||
plugins_call_init_slot(srv, p->handle_waitpid, p->data,
|
||||
offsets[PLUGIN_FUNC_HANDLE_WAITPID]);
|
||||
plugins_call_init_slot(srv, p->handle_subrequest, p->data,
|
||||
offsets[PLUGIN_FUNC_HANDLE_SUBREQUEST]);
|
||||
plugins_call_init_slot(srv, p->handle_subrequest_start, p->data,
|
||||
offsets[PLUGIN_FUNC_HANDLE_SUBREQUEST_START]);
|
||||
plugins_call_init_slot(srv, p->handle_response_start, p->data,
|
||||
|
|
|
@ -69,7 +69,7 @@ struct plugin {
|
|||
handler_t (* handle_connection_shut_wr)(connection *con, void *p_d); /* done writing to socket */
|
||||
handler_t (* handle_connection_close) (connection *con, void *p_d); /* before close() of socket */
|
||||
handler_t (* handle_subrequest_start) (connection *con, void *p_d); /* when handler for request not found yet */
|
||||
handler_t (* handle_subrequest) (connection *con, void *p_d); /* */
|
||||
handler_t (* handle_subrequest) (connection *con, void *p_d); /* handler for request (max one per request) */
|
||||
handler_t (* handle_response_start) (connection *con, void *p_d); /* before response headers are written */
|
||||
handler_t (* connection_reset) (connection *con, void *p_d); /* after request done or request abort */
|
||||
|
||||
|
@ -97,7 +97,6 @@ void plugins_free(server *srv);
|
|||
handler_t plugins_call_handle_uri_raw(connection *con);
|
||||
handler_t plugins_call_handle_uri_clean(connection *con);
|
||||
handler_t plugins_call_handle_subrequest_start(connection *con);
|
||||
handler_t plugins_call_handle_subrequest(connection *con);
|
||||
handler_t plugins_call_handle_response_start(connection *con);
|
||||
handler_t plugins_call_handle_request_env(connection *con);
|
||||
handler_t plugins_call_handle_request_done(connection *con);
|
||||
|
|
|
@ -61,7 +61,7 @@ int http_response_write_header(connection *con) {
|
|||
con->request.keep_alive = 0;
|
||||
} else if (0 != con->request.reqbody_length
|
||||
&& con->request.reqbody_length != con->request.reqbody_queue->bytes_in
|
||||
&& (con->mode == DIRECT || 0 == con->conf.stream_request_body)) {
|
||||
&& (NULL == con->response.handler_module || 0 == con->conf.stream_request_body)) {
|
||||
con->request.keep_alive = 0;
|
||||
} else {
|
||||
con->keep_alive_idle = con->conf.max_keep_alive_idle;
|
||||
|
@ -288,7 +288,7 @@ __attribute_noinline__
|
|||
static handler_t http_status_set_error_close (connection *con, int status) {
|
||||
con->request.keep_alive = 0;
|
||||
con->response.resp_body_finished = 1;
|
||||
con->mode = DIRECT;
|
||||
con->response.handler_module = NULL;
|
||||
con->http_status = status;
|
||||
return HANDLER_FINISHED;
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ handler_t http_response_prepare(connection *con) {
|
|||
handler_t rc;
|
||||
|
||||
/* looks like someone has already done a decision */
|
||||
if (con->mode == DIRECT &&
|
||||
if (NULL == con->response.handler_module &&
|
||||
(con->http_status != 0 && con->http_status != 200)) {
|
||||
/* remove a packets in the queue */
|
||||