[core] parse request in connection_read_header()

personal/stbuehler/fix-fdevent
Glenn Strauss 4 years ago
parent 8426b94161
commit 9ab5469365
  1. 33
      src/connections.c
  2. 20
      src/request.c

@ -762,6 +762,28 @@ static void connection_read_header(server *srv, connection *con) {
chunkqueue_remove_finished_chunks(cq);
if (con->conf.log_request_header) {
log_error_write(srv, __FILE__, __LINE__, "sdsdSb",
"fd:", con->fd,
"request-len:", buffer_string_length(con->request.request),
"\n", con->request.request);
}
buffer_clear(con->uri.authority);
buffer_reset(con->uri.path);
buffer_reset(con->uri.query);
buffer_reset(con->request.orig_uri);
if (0 != http_request_parse(srv, con)) {
con->keep_alive = 0;
con->request.content_length = 0;
if (srv->srvconf.log_request_header_on_error) {
log_error_write(srv, __FILE__, __LINE__, "Sb",
"request-header:\n", con->request.request);
}
}
connection_set_state(srv, con, CON_STATE_REQUEST_END);
}
@ -1229,14 +1251,9 @@ int connection_state_machine(server *srv, connection *con) {
if (con->state != CON_STATE_REQUEST_END) break;
/* fall through */
case CON_STATE_REQUEST_END: /* transient */
buffer_clear(con->uri.authority);
buffer_reset(con->uri.path);
buffer_reset(con->uri.query);
buffer_reset(con->request.orig_uri);
ostate = http_request_parse(srv, con)
? CON_STATE_READ_POST
: CON_STATE_HANDLE_REQUEST;
ostate = (0 == con->request.content_length)
? CON_STATE_HANDLE_REQUEST
: CON_STATE_READ_POST;
connection_set_state(srv, con, ostate);
/* fall through */
case CON_STATE_READ_POST:

@ -597,12 +597,6 @@ static size_t http_request_parse_reqline(server *srv, connection *con, parse_hea
* End : "^$"
*/
if (con->conf.log_request_header) {
log_error_write(srv, __FILE__, __LINE__, "sdsdSb",
"fd:", con->fd,
"request-len:", buffer_string_length(con->request.request),
"\n", con->request.request);
}
if (con->request_count > 1 &&
con->request.request->ptr[0] == '\r' &&
@ -1181,21 +1175,9 @@ int http_request_parse(server *srv, connection *con) {
break;
}
/* check if we have read post data */
if (state.con_length_set) {
/* we have content */
if (con->request.content_length != 0) {
return 1;
}
}
return 0;
failure:
con->keep_alive = 0;
con->response.keep_alive = 0;
if (!con->http_status) con->http_status = 400;
return 0;
return -1;
}

Loading…
Cancel
Save