summaryrefslogtreecommitdiffstats
path: root/src/plugins/http
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2024-08-26 18:26:58 +0200
committerFlorin Coras <florin.coras@gmail.com>2024-08-28 06:08:04 +0000
commit56cefc89e22112071b382fbeb06be839fef1e0ed (patch)
treea19a096f1e1f75b36750b42b757c776a9175f0ac /src/plugins/http
parentd01a63abd41dfd2359e18ca559a0309cfe8c0018 (diff)
http: http_state_wait_app_reply improvement
set http status according to whether app also sent the body Type: improvement Change-Id: Ia41603cc21b410ca6929ec3d3e7c4c6808305769 Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'src/plugins/http')
-rw-r--r--src/plugins/http/http.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/plugins/http/http.c b/src/plugins/http/http.c
index b143893f494..b993daa8224 100644
--- a/src/plugins/http/http.c
+++ b/src/plugins/http/http.c
@@ -1093,6 +1093,7 @@ http_state_wait_app_reply (http_conn_t *hc, transport_send_params_t *sp)
http_status_code_t sc;
http_msg_t msg;
int rv;
+ http_sm_result_t sm_result = HTTP_SM_ERROR;
as = session_get_from_handle (hc->h_pa_session_handle);
@@ -1159,9 +1160,6 @@ http_state_wait_app_reply (http_conn_t *hc, transport_send_params_t *sp)
}
HTTP_DBG (0, "%v", header);
- http_buffer_init (&hc->tx_buf, msg_to_buf_type[msg.data.type], as->tx_fifo,
- msg.data.body_len);
-
offset = http_send_data (hc, header, vec_len (header), 0);
if (offset != vec_len (header))
{
@@ -1172,12 +1170,24 @@ http_state_wait_app_reply (http_conn_t *hc, transport_send_params_t *sp)
}
vec_free (header);
- /* Start sending the actual data */
- http_state_change (hc, HTTP_STATE_APP_IO_MORE_DATA);
+ if (msg.data.body_len)
+ {
+ /* Start sending the actual data */
+ http_buffer_init (&hc->tx_buf, msg_to_buf_type[msg.data.type],
+ as->tx_fifo, msg.data.body_len);
+ http_state_change (hc, HTTP_STATE_APP_IO_MORE_DATA);
+ sm_result = HTTP_SM_CONTINUE;
+ }
+ else
+ {
+ /* No response body, we are done */
+ http_state_change (hc, HTTP_STATE_WAIT_CLIENT_METHOD);
+ sm_result = HTTP_SM_STOP;
+ }
ASSERT (sp->max_burst_size >= offset);
sp->max_burst_size -= offset;
- return HTTP_SM_CONTINUE;
+ return sm_result;
error:
http_send_error (hc, sc);