diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-09-27 16:26:28 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-09-27 17:25:02 +0300 |
commit | b9972291435a373b7d92905f3ba153774e759b6b (patch) | |
tree | 8d183ae4bf606e16791c981e731e2325350ea557 | |
parent | ad43f8663c8343039374e64af7e5c59381ff635c (diff) | |
download | libmicrohttpd-b9972291435a373b7d92905f3ba153774e759b6b.tar.gz libmicrohttpd-b9972291435a373b7d92905f3ba153774e759b6b.zip |
Renamed request processing states for clarity and readability
-rw-r--r-- | src/microhttpd/connection.c | 37 | ||||
-rw-r--r-- | src/microhttpd/internal.c | 8 | ||||
-rw-r--r-- | src/microhttpd/internal.h | 16 |
3 files changed, 31 insertions, 30 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index 7624711a..ddc60d85 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -2280,7 +2280,7 @@ build_connection_chunked_response_footer (struct MHD_Connection *connection) | |||
2280 | mhd_assert (connection->rp.props.chunked); | 2280 | mhd_assert (connection->rp.props.chunked); |
2281 | /* TODO: allow combining of the final footer with the last chunk, | 2281 | /* TODO: allow combining of the final footer with the last chunk, |
2282 | * modify the next assert. */ | 2282 | * modify the next assert. */ |
2283 | mhd_assert (MHD_CONNECTION_BODY_SENT == connection->state); | 2283 | mhd_assert (MHD_CONNECTION_CHUNKED_BODY_SENT == connection->state); |
2284 | mhd_assert (NULL != c->rp.response); | 2284 | mhd_assert (NULL != c->rp.response); |
2285 | 2285 | ||
2286 | buf_size = connection_maximize_write_buffer (c); | 2286 | buf_size = connection_maximize_write_buffer (c); |
@@ -2624,13 +2624,13 @@ MHD_connection_update_event_loop_info (struct MHD_Connection *connection) | |||
2624 | case MHD_CONNECTION_CHUNKED_BODY_UNREADY: | 2624 | case MHD_CONNECTION_CHUNKED_BODY_UNREADY: |
2625 | connection->event_loop_info = MHD_EVENT_LOOP_INFO_BLOCK; | 2625 | connection->event_loop_info = MHD_EVENT_LOOP_INFO_BLOCK; |
2626 | break; | 2626 | break; |
2627 | case MHD_CONNECTION_BODY_SENT: | 2627 | case MHD_CONNECTION_CHUNKED_BODY_SENT: |
2628 | mhd_assert (0); | 2628 | mhd_assert (0); |
2629 | break; | 2629 | break; |
2630 | case MHD_CONNECTION_FOOTERS_SENDING: | 2630 | case MHD_CONNECTION_FOOTERS_SENDING: |
2631 | connection->event_loop_info = MHD_EVENT_LOOP_INFO_WRITE; | 2631 | connection->event_loop_info = MHD_EVENT_LOOP_INFO_WRITE; |
2632 | break; | 2632 | break; |
2633 | case MHD_CONNECTION_FOOTERS_SENT: | 2633 | case MHD_CONNECTION_FULL_REPLY_SENT: |
2634 | mhd_assert (0); | 2634 | mhd_assert (0); |
2635 | break; | 2635 | break; |
2636 | case MHD_CONNECTION_CLOSED: | 2636 | case MHD_CONNECTION_CLOSED: |
@@ -4208,9 +4208,9 @@ MHD_connection_handle_read (struct MHD_Connection *connection, | |||
4208 | case MHD_CONNECTION_NORMAL_BODY_READY: | 4208 | case MHD_CONNECTION_NORMAL_BODY_READY: |
4209 | case MHD_CONNECTION_CHUNKED_BODY_UNREADY: | 4209 | case MHD_CONNECTION_CHUNKED_BODY_UNREADY: |
4210 | case MHD_CONNECTION_CHUNKED_BODY_READY: | 4210 | case MHD_CONNECTION_CHUNKED_BODY_READY: |
4211 | case MHD_CONNECTION_BODY_SENT: | 4211 | case MHD_CONNECTION_CHUNKED_BODY_SENT: |
4212 | case MHD_CONNECTION_FOOTERS_SENDING: | 4212 | case MHD_CONNECTION_FOOTERS_SENDING: |
4213 | case MHD_CONNECTION_FOOTERS_SENT: | 4213 | case MHD_CONNECTION_FULL_REPLY_SENT: |
4214 | default: | 4214 | default: |
4215 | mhd_assert (0); /* Should not be possible */ | 4215 | mhd_assert (0); /* Should not be possible */ |
4216 | } | 4216 | } |
@@ -4466,7 +4466,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection) | |||
4466 | } | 4466 | } |
4467 | if (connection->rp.rsp_write_position == | 4467 | if (connection->rp.rsp_write_position == |
4468 | connection->rp.response->total_size) | 4468 | connection->rp.response->total_size) |
4469 | connection->state = MHD_CONNECTION_FOOTERS_SENT; /* have no footers */ | 4469 | connection->state = MHD_CONNECTION_FULL_REPLY_SENT; |
4470 | return; | 4470 | return; |
4471 | case MHD_CONNECTION_NORMAL_BODY_UNREADY: | 4471 | case MHD_CONNECTION_NORMAL_BODY_UNREADY: |
4472 | mhd_assert (0); | 4472 | mhd_assert (0); |
@@ -4500,11 +4500,11 @@ MHD_connection_handle_write (struct MHD_Connection *connection) | |||
4500 | check_write_done (connection, | 4500 | check_write_done (connection, |
4501 | (connection->rp.response->total_size == | 4501 | (connection->rp.response->total_size == |
4502 | connection->rp.rsp_write_position) ? | 4502 | connection->rp.rsp_write_position) ? |
4503 | MHD_CONNECTION_BODY_SENT : | 4503 | MHD_CONNECTION_CHUNKED_BODY_SENT : |
4504 | MHD_CONNECTION_CHUNKED_BODY_UNREADY); | 4504 | MHD_CONNECTION_CHUNKED_BODY_UNREADY); |
4505 | return; | 4505 | return; |
4506 | case MHD_CONNECTION_CHUNKED_BODY_UNREADY: | 4506 | case MHD_CONNECTION_CHUNKED_BODY_UNREADY: |
4507 | case MHD_CONNECTION_BODY_SENT: | 4507 | case MHD_CONNECTION_CHUNKED_BODY_SENT: |
4508 | mhd_assert (0); | 4508 | mhd_assert (0); |
4509 | return; | 4509 | return; |
4510 | case MHD_CONNECTION_FOOTERS_SENDING: | 4510 | case MHD_CONNECTION_FOOTERS_SENDING: |
@@ -4534,9 +4534,9 @@ MHD_connection_handle_write (struct MHD_Connection *connection) | |||
4534 | if (MHD_CONNECTION_FOOTERS_SENDING != connection->state) | 4534 | if (MHD_CONNECTION_FOOTERS_SENDING != connection->state) |
4535 | return; | 4535 | return; |
4536 | check_write_done (connection, | 4536 | check_write_done (connection, |
4537 | MHD_CONNECTION_FOOTERS_SENT); | 4537 | MHD_CONNECTION_FULL_REPLY_SENT); |
4538 | return; | 4538 | return; |
4539 | case MHD_CONNECTION_FOOTERS_SENT: | 4539 | case MHD_CONNECTION_FULL_REPLY_SENT: |
4540 | mhd_assert (0); | 4540 | mhd_assert (0); |
4541 | return; | 4541 | return; |
4542 | case MHD_CONNECTION_CLOSED: | 4542 | case MHD_CONNECTION_CLOSED: |
@@ -5065,7 +5065,6 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
5065 | /* no default action */ | 5065 | /* no default action */ |
5066 | break; | 5066 | break; |
5067 | case MHD_CONNECTION_HEADERS_SENT: | 5067 | case MHD_CONNECTION_HEADERS_SENT: |
5068 | /* Some clients may take some actions right after header receive */ | ||
5069 | #ifdef UPGRADE_SUPPORT | 5068 | #ifdef UPGRADE_SUPPORT |
5070 | if (NULL != connection->rp.response->upgrade_handler) | 5069 | if (NULL != connection->rp.response->upgrade_handler) |
5071 | { | 5070 | { |
@@ -5099,7 +5098,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
5099 | connection->state = MHD_CONNECTION_NORMAL_BODY_UNREADY; | 5098 | connection->state = MHD_CONNECTION_NORMAL_BODY_UNREADY; |
5100 | } | 5099 | } |
5101 | else | 5100 | else |
5102 | connection->state = MHD_CONNECTION_FOOTERS_SENT; | 5101 | connection->state = MHD_CONNECTION_FULL_REPLY_SENT; |
5103 | continue; | 5102 | continue; |
5104 | case MHD_CONNECTION_NORMAL_BODY_READY: | 5103 | case MHD_CONNECTION_NORMAL_BODY_READY: |
5105 | /* nothing to do here */ | 5104 | /* nothing to do here */ |
@@ -5116,9 +5115,9 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
5116 | MHD_mutex_unlock_chk_ (&connection->rp.response->mutex); | 5115 | MHD_mutex_unlock_chk_ (&connection->rp.response->mutex); |
5117 | #endif | 5116 | #endif |
5118 | if (connection->rp.props.chunked) | 5117 | if (connection->rp.props.chunked) |
5119 | connection->state = MHD_CONNECTION_BODY_SENT; | 5118 | connection->state = MHD_CONNECTION_CHUNKED_BODY_SENT; |
5120 | else | 5119 | else |
5121 | connection->state = MHD_CONNECTION_FOOTERS_SENT; | 5120 | connection->state = MHD_CONNECTION_FULL_REPLY_SENT; |
5122 | continue; | 5121 | continue; |
5123 | } | 5122 | } |
5124 | if (MHD_NO != try_ready_normal_body (connection)) | 5123 | if (MHD_NO != try_ready_normal_body (connection)) |
@@ -5151,7 +5150,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
5151 | if (NULL != connection->rp.response->crc) | 5150 | if (NULL != connection->rp.response->crc) |
5152 | MHD_mutex_unlock_chk_ (&connection->rp.response->mutex); | 5151 | MHD_mutex_unlock_chk_ (&connection->rp.response->mutex); |
5153 | #endif | 5152 | #endif |
5154 | connection->state = MHD_CONNECTION_BODY_SENT; | 5153 | connection->state = MHD_CONNECTION_CHUNKED_BODY_SENT; |
5155 | continue; | 5154 | continue; |
5156 | } | 5155 | } |
5157 | if (1) | 5156 | if (1) |
@@ -5163,14 +5162,14 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
5163 | if (NULL != connection->rp.response->crc) | 5162 | if (NULL != connection->rp.response->crc) |
5164 | MHD_mutex_unlock_chk_ (&connection->rp.response->mutex); | 5163 | MHD_mutex_unlock_chk_ (&connection->rp.response->mutex); |
5165 | #endif | 5164 | #endif |
5166 | connection->state = finished ? MHD_CONNECTION_BODY_SENT : | 5165 | connection->state = finished ? MHD_CONNECTION_CHUNKED_BODY_SENT : |
5167 | MHD_CONNECTION_CHUNKED_BODY_READY; | 5166 | MHD_CONNECTION_CHUNKED_BODY_READY; |
5168 | continue; | 5167 | continue; |
5169 | } | 5168 | } |
5170 | /* mutex was already unlocked by try_ready_chunked_body */ | 5169 | /* mutex was already unlocked by try_ready_chunked_body */ |
5171 | } | 5170 | } |
5172 | break; | 5171 | break; |
5173 | case MHD_CONNECTION_BODY_SENT: | 5172 | case MHD_CONNECTION_CHUNKED_BODY_SENT: |
5174 | mhd_assert (connection->rp.props.chunked); | 5173 | mhd_assert (connection->rp.props.chunked); |
5175 | 5174 | ||
5176 | if (MHD_NO == build_connection_chunked_response_footer (connection)) | 5175 | if (MHD_NO == build_connection_chunked_response_footer (connection)) |
@@ -5185,14 +5184,14 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
5185 | if ( (! connection->rp.props.chunked) || | 5184 | if ( (! connection->rp.props.chunked) || |
5186 | (connection->write_buffer_send_offset == | 5185 | (connection->write_buffer_send_offset == |
5187 | connection->write_buffer_append_offset) ) | 5186 | connection->write_buffer_append_offset) ) |
5188 | connection->state = MHD_CONNECTION_FOOTERS_SENT; | 5187 | connection->state = MHD_CONNECTION_FULL_REPLY_SENT; |
5189 | else | 5188 | else |
5190 | connection->state = MHD_CONNECTION_FOOTERS_SENDING; | 5189 | connection->state = MHD_CONNECTION_FOOTERS_SENDING; |
5191 | continue; | 5190 | continue; |
5192 | case MHD_CONNECTION_FOOTERS_SENDING: | 5191 | case MHD_CONNECTION_FOOTERS_SENDING: |
5193 | /* no default action */ | 5192 | /* no default action */ |
5194 | break; | 5193 | break; |
5195 | case MHD_CONNECTION_FOOTERS_SENT: | 5194 | case MHD_CONNECTION_FULL_REPLY_SENT: |
5196 | if (MHD_HTTP_PROCESSING == connection->rp.responseCode) | 5195 | if (MHD_HTTP_PROCESSING == connection->rp.responseCode) |
5197 | { | 5196 | { |
5198 | /* After this type of response, we allow sending another! */ | 5197 | /* After this type of response, we allow sending another! */ |
diff --git a/src/microhttpd/internal.c b/src/microhttpd/internal.c index 57553251..dee21e9e 100644 --- a/src/microhttpd/internal.c +++ b/src/microhttpd/internal.c | |||
@@ -75,12 +75,12 @@ MHD_state_to_string (enum MHD_CONNECTION_STATE state) | |||
75 | return "chunked body unready"; | 75 | return "chunked body unready"; |
76 | case MHD_CONNECTION_CHUNKED_BODY_READY: | 76 | case MHD_CONNECTION_CHUNKED_BODY_READY: |
77 | return "chunked body ready"; | 77 | return "chunked body ready"; |
78 | case MHD_CONNECTION_BODY_SENT: | 78 | case MHD_CONNECTION_CHUNKED_BODY_SENT: |
79 | return "body sent"; | 79 | return "chunked body sent"; |
80 | case MHD_CONNECTION_FOOTERS_SENDING: | 80 | case MHD_CONNECTION_FOOTERS_SENDING: |
81 | return "footers sending"; | 81 | return "footers sending"; |
82 | case MHD_CONNECTION_FOOTERS_SENT: | 82 | case MHD_CONNECTION_FULL_REPLY_SENT: |
83 | return "footers sent"; | 83 | return "reply sent completely"; |
84 | case MHD_CONNECTION_CLOSED: | 84 | case MHD_CONNECTION_CLOSED: |
85 | return "closed"; | 85 | return "closed"; |
86 | default: | 86 | default: |
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h index adb69b32..37f38eea 100644 --- a/src/microhttpd/internal.h +++ b/src/microhttpd/internal.h | |||
@@ -706,31 +706,33 @@ enum MHD_CONNECTION_STATE | |||
706 | MHD_CONNECTION_CHUNKED_BODY_READY = MHD_CONNECTION_CHUNKED_BODY_UNREADY + 1, | 706 | MHD_CONNECTION_CHUNKED_BODY_READY = MHD_CONNECTION_CHUNKED_BODY_UNREADY + 1, |
707 | 707 | ||
708 | /** | 708 | /** |
709 | * We have sent the response body. Prepare the footers. | 709 | * We have sent the chunked response body. Prepare the footers. |
710 | */ | 710 | */ |
711 | MHD_CONNECTION_BODY_SENT = MHD_CONNECTION_CHUNKED_BODY_READY + 1, | 711 | MHD_CONNECTION_CHUNKED_BODY_SENT = MHD_CONNECTION_CHUNKED_BODY_READY + 1, |
712 | 712 | ||
713 | /** | 713 | /** |
714 | * We have prepared the response footer. Send it. | 714 | * We have prepared the response footer. Send it. |
715 | */ | 715 | */ |
716 | MHD_CONNECTION_FOOTERS_SENDING = MHD_CONNECTION_BODY_SENT + 1, | 716 | MHD_CONNECTION_FOOTERS_SENDING = MHD_CONNECTION_CHUNKED_BODY_SENT + 1, |
717 | 717 | ||
718 | /** | 718 | /** |
719 | * We have sent the response footer. Shutdown or restart. | 719 | * We have sent the entire reply. |
720 | * Shutdown connection or restart processing to get a new request. | ||
720 | */ | 721 | */ |
721 | MHD_CONNECTION_FOOTERS_SENT = MHD_CONNECTION_FOOTERS_SENDING + 1, | 722 | MHD_CONNECTION_FULL_REPLY_SENT = MHD_CONNECTION_FOOTERS_SENDING + 1, |
722 | 723 | ||
723 | /** | 724 | /** |
724 | * This connection is to be closed. | 725 | * This connection is to be closed. |
725 | */ | 726 | */ |
726 | MHD_CONNECTION_CLOSED = MHD_CONNECTION_FOOTERS_SENT + 1, | 727 | MHD_CONNECTION_CLOSED = MHD_CONNECTION_FULL_REPLY_SENT + 1 |
727 | 728 | ||
728 | #ifdef UPGRADE_SUPPORT | 729 | #ifdef UPGRADE_SUPPORT |
730 | , | ||
729 | /** | 731 | /** |
730 | * Connection was "upgraded" and socket is now under the | 732 | * Connection was "upgraded" and socket is now under the |
731 | * control of the application. | 733 | * control of the application. |
732 | */ | 734 | */ |
733 | MHD_CONNECTION_UPGRADE | 735 | MHD_CONNECTION_UPGRADE = MHD_CONNECTION_CLOSED + 1 |
734 | #endif /* UPGRADE_SUPPORT */ | 736 | #endif /* UPGRADE_SUPPORT */ |
735 | 737 | ||
736 | } _MHD_FIXED_ENUM; | 738 | } _MHD_FIXED_ENUM; |