summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2019-02-07 00:34:42 -0500
committerGlenn Strauss <gstrauss@gluelogic.com>2019-02-08 22:49:46 -0500
commit9ab546936590d6c575eef8f0a9b9305dadc48b1b (patch)
tree0ce0f4bda3dd85720345e6a5a9fd8f73a85560df
parent8426b94161e6b4ab10d48b5c97ff66fe8587446c (diff)
downloadlighttpd1.4-9ab546936590d6c575eef8f0a9b9305dadc48b1b.tar.gz
lighttpd1.4-9ab546936590d6c575eef8f0a9b9305dadc48b1b.zip
[core] parse request in connection_read_header()
-rw-r--r--src/connections.c33
-rw-r--r--src/request.c20
2 files changed, 26 insertions, 27 deletions
diff --git a/src/connections.c b/src/connections.c
index ce0f0c15..05e64e73 100644
--- a/src/connections.c
+++ b/src/connections.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:
diff --git a/src/request.c b/src/request.c
index f2d3c527..f9f72979 100644
--- a/src/request.c
+++ b/src/request.c
@@ -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;
}