diff options
author | Semir Sionek <ssionek@cisco.com> | 2025-01-16 09:03:41 -0500 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2025-01-16 21:45:21 +0000 |
commit | ce8adec92b99c8dda9b4792173d14c3068c5d5a2 (patch) | |
tree | cae109252654b611513089cf2da66af88c8e1dfa /src | |
parent | 8d6b2f6d7a8cd78ae42262c4de112f8301e80e18 (diff) |
http: fix sending error responses to rejected requests by server apps
Plugins such as http_static sometimes reject requests without reading
all of the body. http_static in that case sends an error response and
closes the connection. But the error response cannot go out due to the
connection state being HTTP_REQ_STATE_TRANSPORT_IO_MORE_DATA.
With this change, we make http_app_tx_callback give a response like
that special treatment, allowing it to go out.
Type: fix
Change-Id: I72ae74b869183f5d5921837f6ac9c52f0efc7598
Signed-off-by: Semir Sionek <ssionek@cisco.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/http/http.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/plugins/http/http.c b/src/plugins/http/http.c index 5a0c6541598..c33c85a303e 100644 --- a/src/plugins/http/http.c +++ b/src/plugins/http/http.c @@ -2467,13 +2467,24 @@ http_app_tx_callback (void *session, transport_send_params_t *sp) if (!http_req_state_is_tx_valid (hc)) { - clib_warning ("hc [%u]%x invalid tx state: http req state " - "'%U', session state '%U'", - as->thread_index, as->connection_index, - format_http_req_state, hc->req.state, - format_http_conn_state, hc); - svm_fifo_dequeue_drop_all (as->tx_fifo); - return 0; + /* Sometimes the server apps can send the response earlier + * than expected (e.g when rejecting a bad request)*/ + if (hc->req.state == HTTP_REQ_STATE_TRANSPORT_IO_MORE_DATA && + hc->is_server) + { + svm_fifo_dequeue_drop_all (as->rx_fifo); + hc->req.state = HTTP_REQ_STATE_WAIT_APP_REPLY; + } + else + { + clib_warning ("hc [%u]%x invalid tx state: http req state " + "'%U', session state '%U'", + as->thread_index, as->connection_index, + format_http_req_state, hc->req.state, + format_http_conn_state, hc); + svm_fifo_dequeue_drop_all (as->tx_fifo); + return 0; + } } HTTP_DBG (1, "run state machine"); |