diff --git a/src/connections.c b/src/connections.c index 534621bb..58a8bb1c 100644 --- a/src/connections.c +++ b/src/connections.c @@ -1134,7 +1134,12 @@ connection *connection_accepted(server *srv, server_socket *srv_socket, sock_add static int connection_handle_request(request_st * const r) { - int rc = http_response_prepare(r); + const plugin *p = r->handler_module; + int rc; + if (NULL != p + || ((rc = http_response_prepare(r)) == HANDLER_GO_ON + && NULL != (p = r->handler_module))) + rc = p->handle_subrequest(r, p->data); switch (rc) { case HANDLER_WAIT_FOR_EVENT: if (!r->resp_body_finished && (!r->resp_body_started || 0 == r->conf.stream_response_body)) { @@ -1142,6 +1147,7 @@ static int connection_handle_request(request_st * const r) { } /* response headers received from backend; fall through to start response */ /* fall through */ + case HANDLER_GO_ON: /*(HANDLER_FINISHED if request not handled)*/ case HANDLER_FINISHED: if (r->http_status == 0) r->http_status = 200; if (r->error_handler_saved_status > 0) { @@ -1229,13 +1235,10 @@ static int connection_handle_request(request_st * const r) { config_reset_config(r); } return 1; - case HANDLER_ERROR: - /* something went wrong */ - connection_set_state(r, CON_STATE_ERROR); - break; + /*case HANDLER_ERROR:*/ default: + /* something went wrong */ connection_set_state(r, CON_STATE_ERROR); - log_error(r->conf.errh, __FILE__, __LINE__, "unknown ret-value: %d %d", r->con->fd, rc); break; } diff --git a/src/response.c b/src/response.c index 37b2a91a..9c7a31e7 100644 --- a/src/response.c +++ b/src/response.c @@ -298,8 +298,7 @@ handler_t http_response_prepare(request_st * const r) { handler_t rc; /* looks like someone has already done a decision */ - if (NULL == r->handler_module && - (r->http_status != 0 && r->http_status != 200)) { + if (r->http_status != 0 && r->http_status != 200) { /* remove a packets in the queue */ if (r->resp_body_finished == 0) { http_response_body_clear(r, 0); @@ -309,7 +308,7 @@ handler_t http_response_prepare(request_st * const r) { } /* no decision yet, build conf->filename */ - if (NULL == r->handler_module && buffer_is_empty(&r->physical.path)) { + if (buffer_is_empty(&r->physical.path)) { /* we only come here when we have the parse the full request again * @@ -667,13 +666,14 @@ handler_t http_response_prepare(request_st * const r) { } } + if (NULL != r->handler_module) return HANDLER_GO_ON; + /* * Noone catched away the file from normal path of execution yet (like mod_access) * * Go on and check of the file exists at all */ - if (NULL == r->handler_module) { if (r->conf.log_request_handling) { log_error(r->conf.errh, __FILE__, __LINE__, "-- handling physical path"); @@ -711,10 +711,5 @@ handler_t http_response_prepare(request_st * const r) { return HANDLER_FINISHED; } - } - - const plugin * const p = r->handler_module; - rc = (NULL != p) ? p->handle_subrequest(r, p->data) : HANDLER_FINISHED; - if (HANDLER_GO_ON == rc) rc = HANDLER_FINISHED; /* request was not handled, looks like we are done */ - return rc; + return HANDLER_GO_ON; }