Browse Source

[core] dispatch handler in handle_request func

dispatch handler in connection_handle_request()
instead of in http_response_prepare()
personal/stbuehler/ci-build
Glenn Strauss 2 years ago
parent
commit
34285ed0fa
  1. 15
      src/connections.c
  2. 15
      src/response.c

15
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;
}

15
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;
}

Loading…
Cancel
Save