From 085f18f4bedb489c974fb39fff58afbe1e8bb0b7 Mon Sep 17 00:00:00 2001 From: "Evgeny Grin (Karlson2k)" Date: Sun, 24 Nov 2024 09:42:55 +0300 Subject: [PATCH] Renamed CONNECTION_STATE to HTTP_STAGE This is stages of HTTP communication, not states of the connection. --- src/mhd2/conn_data_process.c | 8 +- src/mhd2/conn_data_recv.c | 14 +-- src/mhd2/conn_data_send.c | 100 +++++++-------- src/mhd2/daemon_add_conn.c | 2 +- src/mhd2/events_process.c | 14 +-- src/mhd2/mhd_connection.h | 72 +++++------ src/mhd2/mhd_recv.c | 2 +- src/mhd2/mhd_request.h | 6 +- src/mhd2/mhd_send.c | 6 +- src/mhd2/post_parser_funcs.c | 38 +++--- src/mhd2/request_get_value.c | 2 +- src/mhd2/respond_with_error.c | 4 +- src/mhd2/stream_funcs.c | 24 ++-- src/mhd2/stream_process_reply.c | 18 +-- src/mhd2/stream_process_request.c | 196 +++++++++++++++--------------- src/mhd2/stream_process_states.c | 176 +++++++++++++-------------- src/mhd2/upgrade_prep.c | 12 +- src/mhd2/upgrade_proc.c | 16 +-- src/mhd2/upgraded_net.c | 4 +- 19 files changed, 357 insertions(+), 357 deletions(-) diff --git a/src/mhd2/conn_data_process.c b/src/mhd2/conn_data_process.c index ec4e5368..e4bb489c 100644 --- a/src/mhd2/conn_data_process.c +++ b/src/mhd2/conn_data_process.c @@ -142,10 +142,10 @@ mhd_conn_process_recv_send_data (struct MHD_Connection *restrict c) some data pending in system buffers, use this optimization only for non-blocking sockets. */ /* No need to check 'ret' as connection is always in - * MHD_CONNECTION_CLOSED state if 'ret' is equal 'MHD_NO'. */ + * mhd_HTTP_STAGE_CLOSED state if 'ret' is equal 'MHD_NO'. */ else if (on_fasttrack && c->sk.props.is_nonblck) { - if (MHD_CONNECTION_HEADERS_SENDING == c->state) + if (mhd_HTTP_STAGE_HEADERS_SENDING == c->stage) { MHD_connection_handle_write (c); /* Always call 'MHD_connection_handle_idle()' after each read/write. */ @@ -154,8 +154,8 @@ mhd_conn_process_recv_send_data (struct MHD_Connection *restrict c) /* If all headers were sent by single write_handler() and * response body is prepared by single MHD_connection_handle_idle() * call - continue. */ - if ((MHD_CONNECTION_UNCHUNKED_BODY_READY == c->state) || - (MHD_CONNECTION_CHUNKED_BODY_READY == c->state)) + if ((mhd_HTTP_STAGE_UNCHUNKED_BODY_READY == c->stage) || + (mhd_HTTP_STAGE_CHUNKED_BODY_READY == c->stage)) { MHD_connection_handle_write (c); ret = MHD_connection_handle_idle (c); diff --git a/src/mhd2/conn_data_recv.c b/src/mhd2/conn_data_recv.c index 6c94f6c9..a9736cbd 100644 --- a/src/mhd2/conn_data_recv.c +++ b/src/mhd2/conn_data_recv.c @@ -49,7 +49,7 @@ mhd_conn_data_recv (struct MHD_Connection *restrict c, size_t received; enum mhd_SocketError res; - mhd_assert (MHD_CONNECTION_CLOSED != c->state); + mhd_assert (mhd_HTTP_STAGE_CLOSED != c->stage); mhd_assert (NULL != c->read_buffer); mhd_assert (c->read_buffer_size > c->read_buffer_offset); mhd_assert (! has_err || \ @@ -102,8 +102,8 @@ if ((bytes_read < 0) || socket_error) { if (MHD_ERR_CONNRESET_ == bytes_read) { - if ( (MHD_CONNECTION_INIT < c->state) && - (MHD_CONNECTION_FULL_REQ_RECEIVED > c->state) ) + if ( (mhd_HTTP_STAGE_INIT < c->stage) && + (mhd_HTTP_STAGE_FULL_REQ_RECEIVED > c->stage) ) { #ifdef HAVE_MESSAGES MHD_DLOG (c->daemon, @@ -117,7 +117,7 @@ if ((bytes_read < 0) || socket_error) } #ifdef HAVE_MESSAGES - if (MHD_CONNECTION_INIT != c->state) + if (mhd_HTTP_STAGE_INIT != c->stage) MHD_DLOG (c->daemon, _ ("Connection socket is closed when reading " \ "request due to the error: %s\n"), @@ -133,8 +133,8 @@ if ((bytes_read < 0) || socket_error) if (0 == bytes_read) { /* Remote side closed c. */ // FIXME: Actually NOT! c->sk.state.rmt_shut_wr = true; - if ( (MHD_CONNECTION_INIT < c->state) && - (MHD_CONNECTION_FULL_REQ_RECEIVED > c->state) ) + if ( (mhd_HTTP_STAGE_INIT < c->stage) && + (mhd_HTTP_STAGE_FULL_REQ_RECEIVED > c->stage) ) { #ifdef HAVE_MESSAGES MHD_DLOG (c->daemon, @@ -145,7 +145,7 @@ if (0 == bytes_read) MHD_connection_close_ (c, MHD_REQUEST_TERMINATED_CLIENT_ABORT); } - else if (MHD_CONNECTION_INIT == c->state) + else if (mhd_HTTP_STAGE_INIT == c->stage) /* This termination code cannot be reported to the application * because application has not been informed yet about this request */ MHD_connection_close_ (c, diff --git a/src/mhd2/conn_data_send.c b/src/mhd2/conn_data_send.c index ad90a6be..62cad439 100644 --- a/src/mhd2/conn_data_send.c +++ b/src/mhd2/conn_data_send.c @@ -51,12 +51,12 @@ * If so, transition into "next_state". * * @param connection connection to check write status for - * @param next_state the next state to transition to + * @param next_stage the next state to transition to * @return #MHD_NO if we are not done, #MHD_YES if we are */ static MHD_FN_PAR_NONNULL_ALL_ bool check_write_done (struct MHD_Connection *restrict connection, - enum MHD_CONNECTION_STATE next_state) + enum mhd_HttpStage next_stage) { // TODO: integrate into states processing if ( (connection->write_buffer_append_offset != @@ -66,7 +66,7 @@ check_write_done (struct MHD_Connection *restrict connection, return false; connection->write_buffer_append_offset = 0; connection->write_buffer_send_offset = 0; - connection->state = next_state; + connection->stage = next_stage; return true; } @@ -91,9 +91,9 @@ mhd_conn_data_send (struct MHD_Connection *restrict c) res = mhd_SOCKET_ERR_INTERNAL; - switch (c->state) + switch (c->stage) { - case MHD_CONNECTION_CONTINUE_SENDING: + case mhd_HTTP_STAGE_CONTINUE_SENDING: res = mhd_send_data (c, http_100_continue_msg_len - c->continue_message_write_offset, @@ -104,7 +104,7 @@ mhd_conn_data_send (struct MHD_Connection *restrict c) if (mhd_SOCKET_ERR_NO_ERROR == res) c->continue_message_write_offset += sent; break; - case MHD_CONNECTION_HEADERS_SENDING: + case mhd_HTTP_STAGE_HEADERS_SENDING: if (1) { struct MHD_Response *const restrict resp = c->rp.response; @@ -154,7 +154,7 @@ mhd_conn_data_send (struct MHD_Connection *restrict c) } if (mhd_SOCKET_ERR_NO_ERROR == res) { - mhd_assert (MHD_CONNECTION_HEADERS_SENDING == c->state); + mhd_assert (mhd_HTTP_STAGE_HEADERS_SENDING == c->stage); if (sent > wb_ready) { @@ -163,30 +163,30 @@ mhd_conn_data_send (struct MHD_Connection *restrict c) mhd_assert (0 == c->rp.rsp_cntn_read_pos); mhd_assert (! c->rp.props.chunked); mhd_assert (c->rp.props.send_reply_body); - c->state = MHD_CONNECTION_UNCHUNKED_BODY_READY; + c->stage = mhd_HTTP_STAGE_UNCHUNKED_BODY_READY; c->write_buffer_send_offset += wb_ready; c->rp.rsp_cntn_read_pos = sent - wb_ready; if (c->rp.rsp_cntn_read_pos == c->rp.response->cntn_size) - c->state = MHD_CONNECTION_FULL_REPLY_SENT; + c->stage = mhd_HTTP_STAGE_FULL_REPLY_SENT; } else { c->write_buffer_send_offset += sent; // TODO: move it to data processing check_write_done (c, - MHD_CONNECTION_HEADERS_SENT); + mhd_HTTP_STAGE_HEADERS_SENT); } } } break; - case MHD_CONNECTION_UNCHUNKED_BODY_READY: - case MHD_CONNECTION_CHUNKED_BODY_READY: + case mhd_HTTP_STAGE_UNCHUNKED_BODY_READY: + case mhd_HTTP_STAGE_CHUNKED_BODY_READY: if (1) { struct MHD_Response *const restrict resp = c->rp.response; mhd_assert (c->rp.props.send_reply_body); mhd_assert (c->rp.rsp_cntn_read_pos < resp->cntn_size); - mhd_assert ((MHD_CONNECTION_CHUNKED_BODY_READY != c->state) || \ + mhd_assert ((mhd_HTTP_STAGE_CHUNKED_BODY_READY != c->stage) || \ (mhd_REPLY_CNTN_LOC_CONN_BUF == c->rp.cntn_loc)); if (mhd_REPLY_CNTN_LOC_RESP_BUF == c->rp.cntn_loc) { @@ -232,7 +232,7 @@ mhd_conn_data_send (struct MHD_Connection *restrict c) { /* Switch to filereader */ mhd_assert (! c->rp.props.chunked); c->rp.cntn_loc = mhd_REPLY_CNTN_LOC_CONN_BUF; - c->state = MHD_CONNECTION_UNCHUNKED_BODY_UNREADY; + c->stage = mhd_HTTP_STAGE_UNCHUNKED_BODY_UNREADY; } } } @@ -247,32 +247,32 @@ mhd_conn_data_send (struct MHD_Connection *restrict c) { if (mhd_REPLY_CNTN_LOC_CONN_BUF == c->rp.cntn_loc) { - enum MHD_CONNECTION_STATE next_state; + enum mhd_HttpStage next_stage; c->write_buffer_send_offset += sent; // TODO: move it to data processing - if (MHD_CONNECTION_CHUNKED_BODY_READY == c->state) - next_state = + if (mhd_HTTP_STAGE_CHUNKED_BODY_READY == c->stage) + next_stage = (c->rp.response->cntn_size == c->rp.rsp_cntn_read_pos) ? - MHD_CONNECTION_CHUNKED_BODY_SENT : - MHD_CONNECTION_CHUNKED_BODY_UNREADY; + mhd_HTTP_STAGE_CHUNKED_BODY_SENT : + mhd_HTTP_STAGE_CHUNKED_BODY_UNREADY; else - next_state = + next_stage = (c->rp.rsp_cntn_read_pos == resp->cntn_size) ? - MHD_CONNECTION_FULL_REPLY_SENT : - MHD_CONNECTION_UNCHUNKED_BODY_UNREADY; + mhd_HTTP_STAGE_FULL_REPLY_SENT : + mhd_HTTP_STAGE_UNCHUNKED_BODY_UNREADY; check_write_done (c, - next_state); + next_stage); } else { c->rp.rsp_cntn_read_pos += sent; if (c->rp.rsp_cntn_read_pos == resp->cntn_size) - c->state = MHD_CONNECTION_FULL_REPLY_SENT; + c->stage = mhd_HTTP_STAGE_FULL_REPLY_SENT; } } } break; - case MHD_CONNECTION_FOOTERS_SENDING: + case mhd_HTTP_STAGE_FOOTERS_SENDING: res = mhd_send_data (c, c->write_buffer_append_offset - c->write_buffer_send_offset, @@ -285,11 +285,11 @@ mhd_conn_data_send (struct MHD_Connection *restrict c) c->write_buffer_send_offset += sent; // TODO: move it to data processing check_write_done (c, - MHD_CONNECTION_FULL_REPLY_SENT); + mhd_HTTP_STAGE_FULL_REPLY_SENT); } break; #ifdef MHD_UPGRADE_SUPPORT - case MHD_CONNECTION_UPGRADE_HEADERS_SENDING: + case mhd_HTTP_STAGE_UPGRADE_HEADERS_SENDING: res = mhd_send_data (c, c->write_buffer_append_offset - c->write_buffer_send_offset, @@ -301,30 +301,30 @@ mhd_conn_data_send (struct MHD_Connection *restrict c) c->write_buffer_send_offset += sent; break; #endif /* MHD_UPGRADE_SUPPORT */ - case MHD_CONNECTION_INIT: - case MHD_CONNECTION_REQ_LINE_RECEIVING: - case MHD_CONNECTION_REQ_LINE_RECEIVED: - case MHD_CONNECTION_REQ_HEADERS_RECEIVING: - case MHD_CONNECTION_HEADERS_RECEIVED: - case MHD_CONNECTION_HEADERS_PROCESSED: - case MHD_CONNECTION_BODY_RECEIVING: - case MHD_CONNECTION_BODY_RECEIVED: - case MHD_CONNECTION_FOOTERS_RECEIVING: - case MHD_CONNECTION_FOOTERS_RECEIVED: - case MHD_CONNECTION_FULL_REQ_RECEIVED: - case MHD_CONNECTION_REQ_RECV_FINISHED: - case MHD_CONNECTION_START_REPLY: - case MHD_CONNECTION_HEADERS_SENT: - case MHD_CONNECTION_UNCHUNKED_BODY_UNREADY: - case MHD_CONNECTION_CHUNKED_BODY_UNREADY: - case MHD_CONNECTION_CHUNKED_BODY_SENT: - case MHD_CONNECTION_FULL_REPLY_SENT: - case MHD_CONNECTION_PRE_CLOSING: - case MHD_CONNECTION_CLOSED: + case mhd_HTTP_STAGE_INIT: + case mhd_HTTP_STAGE_REQ_LINE_RECEIVING: + case mhd_HTTP_STAGE_REQ_LINE_RECEIVED: + case mhd_HTTP_STAGE_REQ_HEADERS_RECEIVING: + case mhd_HTTP_STAGE_HEADERS_RECEIVED: + case mhd_HTTP_STAGE_HEADERS_PROCESSED: + case mhd_HTTP_STAGE_BODY_RECEIVING: + case mhd_HTTP_STAGE_BODY_RECEIVED: + case mhd_HTTP_STAGE_FOOTERS_RECEIVING: + case mhd_HTTP_STAGE_FOOTERS_RECEIVED: + case mhd_HTTP_STAGE_FULL_REQ_RECEIVED: + case mhd_HTTP_STAGE_REQ_RECV_FINISHED: + case mhd_HTTP_STAGE_START_REPLY: + case mhd_HTTP_STAGE_HEADERS_SENT: + case mhd_HTTP_STAGE_UNCHUNKED_BODY_UNREADY: + case mhd_HTTP_STAGE_CHUNKED_BODY_UNREADY: + case mhd_HTTP_STAGE_CHUNKED_BODY_SENT: + case mhd_HTTP_STAGE_FULL_REPLY_SENT: + case mhd_HTTP_STAGE_PRE_CLOSING: + case mhd_HTTP_STAGE_CLOSED: #ifdef MHD_UPGRADE_SUPPORT - case MHD_CONNECTION_UPGRADING: - case MHD_CONNECTION_UPGRADED: - case MHD_CONNECTION_UPGRADED_CLEANING: + case mhd_HTTP_STAGE_UPGRADING: + case mhd_HTTP_STAGE_UPGRADED: + case mhd_HTTP_STAGE_UPGRADED_CLEANING: #endif /* MHD_UPGRADE_SUPPORT */ mhd_assert (0 && "Should be unreachable"); MHD_UNREACHABLE_; diff --git a/src/mhd2/daemon_add_conn.c b/src/mhd2/daemon_add_conn.c index 174467fe..c2ff2f90 100644 --- a/src/mhd2/daemon_add_conn.c +++ b/src/mhd2/daemon_add_conn.c @@ -84,7 +84,7 @@ connection_set_initial_state (struct MHD_Connection *restrict c) { size_t read_buf_size; - mhd_assert (MHD_CONNECTION_INIT == c->state); + mhd_assert (mhd_HTTP_STAGE_INIT == c->stage); c->conn_reuse = mhd_CONN_KEEPALIVE_POSSIBLE; c->event_loop_info = MHD_EVENT_LOOP_INFO_RECV; diff --git a/src/mhd2/events_process.c b/src/mhd2/events_process.c index 4ae304c5..f54fc485 100644 --- a/src/mhd2/events_process.c +++ b/src/mhd2/events_process.c @@ -247,8 +247,8 @@ is_conn_excluded_from_http_comm (struct MHD_Connection *restrict c) #ifdef MHD_UPGRADE_SUPPORT if (NULL != c->upgr.c) { - mhd_assert ((MHD_CONNECTION_UPGRADED == c->state) || \ - (MHD_CONNECTION_UPGRADED_CLEANING == c->state)); + mhd_assert ((mhd_HTTP_STAGE_UPGRADED == c->stage) || \ + (mhd_HTTP_STAGE_UPGRADED_CLEANING == c->stage)); return true; } #endif /* MHD_UPGRADE_SUPPORT */ @@ -306,7 +306,7 @@ daemon_cleanup_upgraded_conns (struct MHD_Daemon *restrict d) if (NULL == c) break; - mhd_assert (MHD_CONNECTION_UPGRADED_CLEANING == c->state); + mhd_assert (mhd_HTTP_STAGE_UPGRADED_CLEANING == c->stage); mhd_upgraded_deinit (c); mhd_conn_pre_clean (c); mhd_conn_remove_from_daemon (c); @@ -333,8 +333,8 @@ close_all_daemon_conns (struct MHD_Daemon *d) c = mhd_DLINKEDL_GET_LAST (&(d->conns),all_conn)) { #ifdef MHD_UPGRADE_SUPPORT - mhd_assert (MHD_CONNECTION_UPGRADING != c->state); - mhd_assert (MHD_CONNECTION_UPGRADED_CLEANING != c->state); + mhd_assert (mhd_HTTP_STAGE_UPGRADING != c->stage); + mhd_assert (mhd_HTTP_STAGE_UPGRADED_CLEANING != c->stage); if (NULL != c->upgr.c) { mhd_assert (c == c->upgr.c); @@ -459,7 +459,7 @@ select_update_fdsets (struct MHD_Daemon *restrict d, for (c = mhd_DLINKEDL_GET_FIRST (&(d->conns),all_conn); NULL != c; c = mhd_DLINKEDL_GET_NEXT (c,all_conn)) { - mhd_assert (MHD_CONNECTION_CLOSED != c->state); + mhd_assert (mhd_HTTP_STAGE_CLOSED != c->stage); if (is_conn_excluded_from_http_comm (c)) continue; @@ -729,7 +729,7 @@ poll_update_fds (struct MHD_Daemon *restrict d, mhd_assert ((i_c - i_s) < d->conns.cfg.count_limit); mhd_assert (i_c < d->dbg.num_events_elements); - mhd_assert (MHD_CONNECTION_CLOSED != c->state); + mhd_assert (mhd_HTTP_STAGE_CLOSED != c->stage); d->events.data.poll.fds[i_c].fd = c->sk.fd; d->events.data.poll.rel[i_c].connection = c; diff --git a/src/mhd2/mhd_connection.h b/src/mhd2/mhd_connection.h index 913920ec..1f122db9 100644 --- a/src/mhd2/mhd_connection.h +++ b/src/mhd2/mhd_connection.h @@ -171,187 +171,187 @@ enum mhd_ConnClosureReason /** * States in a state machine for a connection. * - * The main transitions are any-state to #MHD_CONNECTION_CLOSED, any - * state to state+1, #MHD_CONNECTION_FOOTERS_SENT to - * #MHD_CONNECTION_INIT. #MHD_CONNECTION_CLOSED is the terminal state - * and #MHD_CONNECTION_INIT the initial state. + * The main transitions are any-state to #mhd_HTTP_STAGE_CLOSED, any + * state to state+1, #mhd_HTTP_STAGE_FOOTERS_SENT to + * #mhd_HTTP_STAGE_INIT. #mhd_HTTP_STAGE_CLOSED is the terminal state + * and #mhd_HTTP_STAGE_INIT the initial state. * * Note that transitions for *reading* happen only after the input has * been processed; transitions for *writing* happen after the * respective data has been put into the write buffer (the write does * not have to be completed yet). A transition to - * #MHD_CONNECTION_CLOSED or #MHD_CONNECTION_INIT requires the write + * #mhd_HTTP_STAGE_CLOSED or #mhd_HTTP_STAGE_INIT requires the write * to be complete. */ -enum MHD_FIXED_ENUM_ MHD_CONNECTION_STATE +enum MHD_FIXED_ENUM_ mhd_HttpStage { /** * Connection just started (no headers received). * Waiting for the line with the request type, URL and version. */ - MHD_CONNECTION_INIT = 0 + mhd_HTTP_STAGE_INIT = 0 , /** * Part of the request line was received. * Wait for complete line. */ - MHD_CONNECTION_REQ_LINE_RECEIVING + mhd_HTTP_STAGE_REQ_LINE_RECEIVING , /** * We got the URL (and request type and version). Wait for a header line. * * A milestone state. No received data is processed in this state. */ - MHD_CONNECTION_REQ_LINE_RECEIVED + mhd_HTTP_STAGE_REQ_LINE_RECEIVED , /** * Receiving request headers. Wait for the rest of the headers. */ - MHD_CONNECTION_REQ_HEADERS_RECEIVING + mhd_HTTP_STAGE_REQ_HEADERS_RECEIVING , /** * We got the request headers. Process them. */ - MHD_CONNECTION_HEADERS_RECEIVED + mhd_HTTP_STAGE_HEADERS_RECEIVED , /** * We have processed the request headers. Call application callback. */ - MHD_CONNECTION_HEADERS_PROCESSED + mhd_HTTP_STAGE_HEADERS_PROCESSED , /** * We have processed the headers and need to send 100 CONTINUE. */ - MHD_CONNECTION_CONTINUE_SENDING + mhd_HTTP_STAGE_CONTINUE_SENDING , /** * We have sent 100 CONTINUE (or do not need to). Read the message body. */ - MHD_CONNECTION_BODY_RECEIVING + mhd_HTTP_STAGE_BODY_RECEIVING , /** * We got the request body. * * A milestone state. No received data is processed in this state. */ - MHD_CONNECTION_BODY_RECEIVED + mhd_HTTP_STAGE_BODY_RECEIVED , /** * We are reading the request footers. */ - MHD_CONNECTION_FOOTERS_RECEIVING + mhd_HTTP_STAGE_FOOTERS_RECEIVING , /** * We received the entire footer. * * A milestone state. No data is receiving in this state. */ - MHD_CONNECTION_FOOTERS_RECEIVED + mhd_HTTP_STAGE_FOOTERS_RECEIVED , /** * We received the entire request. * * A milestone state. No data is receiving in this state. */ - MHD_CONNECTION_FULL_REQ_RECEIVED + mhd_HTTP_STAGE_FULL_REQ_RECEIVED , /** * Finished receiving request data: either complete request received or * MHD is going to send reply early, without getting full request. */ - MHD_CONNECTION_REQ_RECV_FINISHED + mhd_HTTP_STAGE_REQ_RECV_FINISHED , /** * Finished reading of the request and the response is ready. * Switch internal logic from receiving to sending, prepare connection * sending the reply and build the reply header. */ - MHD_CONNECTION_START_REPLY + mhd_HTTP_STAGE_START_REPLY , /** * We have prepared the response headers in the write buffer. * Send the response headers. */ - MHD_CONNECTION_HEADERS_SENDING + mhd_HTTP_STAGE_HEADERS_SENDING , /** * We have sent the response headers. Get ready to send the body. */ - MHD_CONNECTION_HEADERS_SENT + mhd_HTTP_STAGE_HEADERS_SENT #ifdef MHD_UPGRADE_SUPPORT , /** * Sending special HTTP "Upgrade" headers */ - MHD_CONNECTION_UPGRADE_HEADERS_SENDING + mhd_HTTP_STAGE_UPGRADE_HEADERS_SENDING #endif /* MHD_UPGRADE_SUPPORT */ , /** * We are waiting for the client to provide more * data of a non-chunked body. */ - MHD_CONNECTION_UNCHUNKED_BODY_UNREADY + mhd_HTTP_STAGE_UNCHUNKED_BODY_UNREADY , /** * We are ready to send a part of a non-chunked body. Send it. */ - MHD_CONNECTION_UNCHUNKED_BODY_READY + mhd_HTTP_STAGE_UNCHUNKED_BODY_READY , /** * We are waiting for the client to provide a chunk of the body. */ - MHD_CONNECTION_CHUNKED_BODY_UNREADY + mhd_HTTP_STAGE_CHUNKED_BODY_UNREADY , /** * We are ready to send a chunk. */ - MHD_CONNECTION_CHUNKED_BODY_READY + mhd_HTTP_STAGE_CHUNKED_BODY_READY , /** * We have sent the chunked response body. Prepare the footers. */ - MHD_CONNECTION_CHUNKED_BODY_SENT + mhd_HTTP_STAGE_CHUNKED_BODY_SENT , /** * We have prepared the response footer. Send it. */ - MHD_CONNECTION_FOOTERS_SENDING + mhd_HTTP_STAGE_FOOTERS_SENDING , /** * We have sent the entire reply. * Shutdown connection or restart processing to get a new request. */ - MHD_CONNECTION_FULL_REPLY_SENT + mhd_HTTP_STAGE_FULL_REPLY_SENT #ifdef MHD_UPGRADE_SUPPORT , /** * Transition to "Upgraded" state */ - MHD_CONNECTION_UPGRADING + mhd_HTTP_STAGE_UPGRADING , /** * Sending and receiving data on HTTP-Upgraded connection channel. * Normal data processing and connection handling is not performed * by MHD anymore. */ - MHD_CONNECTION_UPGRADED + mhd_HTTP_STAGE_UPGRADED , /** * Closing HTTP-Upgraded connection */ - MHD_CONNECTION_UPGRADED_CLEANING + mhd_HTTP_STAGE_UPGRADED_CLEANING #endif /* MHD_UPGRADE_SUPPORT */ , /** * Finished regular connection processing. * Initial buffers cleanup and freeing. */ - MHD_CONNECTION_PRE_CLOSING + mhd_HTTP_STAGE_PRE_CLOSING , /** * This connection is to be closed. */ - MHD_CONNECTION_CLOSED + mhd_HTTP_STAGE_CLOSED }; @@ -596,7 +596,7 @@ struct MHD_Connection /** * State in the FSM for this connection. */ - enum MHD_CONNECTION_STATE state; + enum mhd_HttpStage stage; /** * What is this connection waiting for? diff --git a/src/mhd2/mhd_recv.c b/src/mhd2/mhd_recv.c index 2c49296e..f4e9c0a9 100644 --- a/src/mhd2/mhd_recv.c +++ b/src/mhd2/mhd_recv.c @@ -84,7 +84,7 @@ mhd_recv (struct MHD_Connection *restrict c, size_t *restrict received) { mhd_assert (MHD_INVALID_SOCKET != c->sk.fd); - mhd_assert (MHD_CONNECTION_CLOSED != c->state); + mhd_assert (mhd_HTTP_STAGE_CLOSED != c->stage); // TODO: implement TLS support diff --git a/src/mhd2/mhd_request.h b/src/mhd2/mhd_request.h index 90478264..b59c7ada 100644 --- a/src/mhd2/mhd_request.h +++ b/src/mhd2/mhd_request.h @@ -366,7 +366,7 @@ struct MHD_Request /** * Number of bytes we had in the HTTP header, set once we - * pass #MHD_CONNECTION_HEADERS_RECEIVED. + * pass #mhd_HTTP_STAGE_HEADERS_RECEIVED. * This includes the request line, all request headers, the header section * terminating empty line, with all CRLF (or LF) characters. */ @@ -375,8 +375,8 @@ struct MHD_Request /** * The union of the size of all request field lines (headers) and * the starting point of the first request field line (the first header). - * Until #MHD_CONNECTION_HEADERS_RECEIVED the @a start member is valid, - * staring with #MHD_CONNECTION_HEADERS_RECEIVED the @a size member is valid. + * Until #mhd_HTTP_STAGE_HEADERS_RECEIVED the @a start member is valid, + * staring with #mhd_HTTP_STAGE_HEADERS_RECEIVED the @a size member is valid. * The size includes CRLF (or LR) characters, but does not include * the terminating empty line. */ diff --git a/src/mhd2/mhd_send.c b/src/mhd2/mhd_send.c index bb4946f4..3a7010fb 100644 --- a/src/mhd2/mhd_send.c +++ b/src/mhd2/mhd_send.c @@ -828,7 +828,7 @@ mhd_send_data (struct MHD_Connection *restrict connection, const bool tls_conn = false; // TODO: TLS support mhd_assert (MHD_INVALID_SOCKET != connection->sk.fd); - mhd_assert (MHD_CONNECTION_CLOSED != connection->state); + mhd_assert (mhd_HTTP_STAGE_CLOSED != connection->stage); if (tls_conn) { @@ -901,7 +901,7 @@ mhd_send_hdr_and_body (struct MHD_Connection *restrict connection, mhd_assert ( (NULL != body) || (0 == body_size) ); mhd_assert (MHD_INVALID_SOCKET != s); - mhd_assert (MHD_CONNECTION_CLOSED != connection->state); + mhd_assert (mhd_HTTP_STAGE_CLOSED != connection->stage); push_body = complete_response; @@ -1376,7 +1376,7 @@ send_iov_nontls (struct MHD_Connection *restrict connection, // TODO: assert for non-TLS mhd_assert (MHD_INVALID_SOCKET != connection->sk.fd); - mhd_assert (MHD_CONNECTION_CLOSED != connection->state); + mhd_assert (mhd_HTTP_STAGE_CLOSED != connection->stage); send_error = false; items_to_send = r_iov->cnt - r_iov->sent; diff --git a/src/mhd2/post_parser_funcs.c b/src/mhd2/post_parser_funcs.c index 695a3786..b4fee496 100644 --- a/src/mhd2/post_parser_funcs.c +++ b/src/mhd2/post_parser_funcs.c @@ -183,7 +183,7 @@ detect_post_enc (struct MHD_Connection *restrict c) { const struct MHD_StringNullable *h_cnt_tp; - mhd_assert (MHD_CONNECTION_BODY_RECEIVING > c->state); + mhd_assert (mhd_HTTP_STAGE_BODY_RECEIVING > c->stage); h_cnt_tp = mhd_request_get_value_st (&(c->rq), MHD_VK_HEADER, @@ -416,7 +416,7 @@ mhd_stream_prepare_for_post_parse (struct MHD_Connection *restrict c) { mhd_assert (MHD_POST_PARSE_RES_OK != c->rq.u_proc.post.parse_result); c->discard_request = true; - c->state = MHD_CONNECTION_FULL_REQ_RECEIVED; + c->stage = mhd_HTTP_STAGE_FULL_REQ_RECEIVED; return false; } } @@ -427,7 +427,7 @@ mhd_stream_prepare_for_post_parse (struct MHD_Connection *restrict c) { mhd_assert (MHD_POST_PARSE_RES_OK != c->rq.u_proc.post.parse_result); c->discard_request = true; - c->state = MHD_CONNECTION_FULL_REQ_RECEIVED; + c->stage = mhd_HTTP_STAGE_FULL_REQ_RECEIVED; return false; } } @@ -550,10 +550,10 @@ report_low_lbuf_mem (struct MHD_Connection *restrict c) "parse POST request."); c->rq.u_proc.post.parse_result = MHD_POST_PARSE_RES_FAILED_NO_LARGE_BUF_MEM; - if (c->state < MHD_CONNECTION_FULL_REQ_RECEIVED) + if (c->stage < mhd_HTTP_STAGE_FULL_REQ_RECEIVED) { c->discard_request = true; - c->state = MHD_CONNECTION_FULL_REQ_RECEIVED; + c->stage = mhd_HTTP_STAGE_FULL_REQ_RECEIVED; return true; } @@ -771,15 +771,15 @@ process_complete_field_all (struct MHD_Connection *restrict c, mhd_assert ((0 == enc_start) || \ (MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA == p_data->enc)); - mhd_assert (MHD_CONNECTION_REQ_RECV_FINISHED >= c->state); + mhd_assert (mhd_HTTP_STAGE_REQ_RECV_FINISHED >= c->stage); mhd_assert (value_start + value_len <= *pfield_next_pos); - mhd_assert ((MHD_CONNECTION_FULL_REQ_RECEIVED <= c->state) || \ + mhd_assert ((mhd_HTTP_STAGE_FULL_REQ_RECEIVED <= c->stage) || \ (value_start + value_len < *pfield_next_pos)); mhd_assert (*pfield_next_pos <= *pdata_size); mhd_assert ((name_start + name_len < value_start) || \ (0 == value_start)); mhd_assert (value_start + value_len <= *pfield_next_pos); - mhd_assert ((MHD_CONNECTION_FULL_REQ_RECEIVED <= c->state) || \ + mhd_assert ((mhd_HTTP_STAGE_FULL_REQ_RECEIVED <= c->stage) || \ (name_start + name_len < *pfield_next_pos)); mhd_assert ((filename_start + filename_len < value_start) || \ (0 == value_start)); @@ -889,7 +889,7 @@ process_complete_field_all (struct MHD_Connection *restrict c, &encoding_i, &value_i)) { - c->state = MHD_CONNECTION_FULL_REQ_RECEIVED; + c->stage = mhd_HTTP_STAGE_FULL_REQ_RECEIVED; mhd_LOG_MSG (c->daemon, MHD_SC_REQ_POST_PARSE_FAILED_NO_POOL_MEM, \ "The request POST data cannot be parsed completely " \ "because there is not enough pool memory."); @@ -933,14 +933,14 @@ process_complete_field (struct MHD_Connection *restrict c, size_t value_start, size_t value_len) { - mhd_assert (MHD_CONNECTION_REQ_RECV_FINISHED >= c->state); + mhd_assert (mhd_HTTP_STAGE_REQ_RECV_FINISHED >= c->stage); mhd_assert (value_start + value_len <= *pfield_next_pos); - mhd_assert ((MHD_CONNECTION_FULL_REQ_RECEIVED <= c->state) || \ + mhd_assert ((mhd_HTTP_STAGE_FULL_REQ_RECEIVED <= c->stage) || \ (value_start + value_len < *pfield_next_pos)); mhd_assert ((name_start + name_len < value_start) || \ (0 == value_start)); mhd_assert (name_start + name_len <= *pfield_next_pos); - mhd_assert ((MHD_CONNECTION_FULL_REQ_RECEIVED <= c->state) || \ + mhd_assert ((mhd_HTTP_STAGE_FULL_REQ_RECEIVED <= c->stage) || \ (name_start + name_len < *pfield_next_pos)); mhd_assert (field_start <= name_start); mhd_assert ((field_start <= value_start) || (0 == value_start)); @@ -1018,7 +1018,7 @@ process_partial_value_all (struct MHD_Connection *restrict c, const struct MHD_UploadAction *act; bool res; - mhd_assert (MHD_CONNECTION_REQ_RECV_FINISHED >= c->state); + mhd_assert (mhd_HTTP_STAGE_REQ_RECV_FINISHED >= c->stage); mhd_assert (*pnext_pos <= *pdata_size); mhd_assert (part_value_start + part_value_len <= *pnext_pos); mhd_assert (0 != part_value_start); @@ -1119,7 +1119,7 @@ process_partial_value (struct MHD_Connection *restrict c, size_t part_value_start, size_t part_value_len) { - mhd_assert (MHD_CONNECTION_REQ_RECV_FINISHED >= c->state); + mhd_assert (mhd_HTTP_STAGE_REQ_RECV_FINISHED >= c->stage); mhd_assert (part_value_start + part_value_len <= *pnext_pos); mhd_assert (name_start + name_len < part_value_start); mhd_assert (0 != part_value_start); @@ -1840,7 +1840,7 @@ parse_post_mpart (struct MHD_Connection *restrict c, p_data->some_data_provided ? MHD_POST_PARSE_RES_PARTIAL_INVALID_POST_FORMAT : MHD_POST_PARSE_RES_FAILED_INVALID_POST_FORMAT; - c->state = MHD_CONNECTION_FULL_REQ_RECEIVED; + c->stage = mhd_HTTP_STAGE_FULL_REQ_RECEIVED; return true; /* Stop parsing the upload */ } mhd_assert (0 != mf->f.name_len); @@ -2063,7 +2063,7 @@ parse_post_mpart (struct MHD_Connection *restrict c, p_data->parse_result = MHD_POST_PARSE_RES_FAILED_INVALID_POST_FORMAT; } - c->state = MHD_CONNECTION_FULL_REQ_RECEIVED; + c->stage = mhd_HTTP_STAGE_FULL_REQ_RECEIVED; return true; default: mhd_assert (0 && "Impossible value"); @@ -2320,7 +2320,7 @@ parse_post_text (struct MHD_Connection *restrict c, MHD_POST_PARSE_RES_FAILED_INVALID_POST_FORMAT; } tf->st = mhd_POST_TEXT_ST_NOT_STARTED; - c->state = MHD_CONNECTION_FULL_REQ_RECEIVED; + c->stage = mhd_HTTP_STAGE_FULL_REQ_RECEIVED; return true; } @@ -2426,7 +2426,7 @@ mhd_stream_post_parse (struct MHD_Connection *restrict c, MHD_UNREACHABLE_; p_data->parse_result = MHD_POST_PARSE_RES_PARTIAL_INVALID_POST_FORMAT; - c->state = MHD_CONNECTION_FULL_REQ_RECEIVED; + c->stage = mhd_HTTP_STAGE_FULL_REQ_RECEIVED; return true; } if (data_size_before_parse == p_data->lbuf_used) @@ -2908,7 +2908,7 @@ check_post_leftovers (struct MHD_Connection *restrict c) MHD_UNREACHABLE_; p_data->parse_result = MHD_POST_PARSE_RES_PARTIAL_INVALID_POST_FORMAT; - c->state = MHD_CONNECTION_FULL_REQ_RECEIVED; + c->stage = mhd_HTTP_STAGE_FULL_REQ_RECEIVED; break; } return true; diff --git a/src/mhd2/request_get_value.c b/src/mhd2/request_get_value.c index 3737808d..024ac94d 100644 --- a/src/mhd2/request_get_value.c +++ b/src/mhd2/request_get_value.c @@ -119,7 +119,7 @@ mhd_stream_has_header_token (const struct MHD_Connection *restrict c, { struct mhd_RequestField *f; - mhd_assert (MHD_CONNECTION_START_REPLY >= c->state); + mhd_assert (mhd_HTTP_STAGE_START_REPLY >= c->stage); for (f = mhd_DLINKEDL_GET_FIRST (&(c->rq), fields); NULL != f; diff --git a/src/mhd2/respond_with_error.c b/src/mhd2/respond_with_error.c index 82c4ef52..5ac49106 100644 --- a/src/mhd2/respond_with_error.c +++ b/src/mhd2/respond_with_error.c @@ -58,7 +58,7 @@ respond_with_error_len (struct MHD_Connection *c, struct MHD_Response *err_res; mhd_assert (! c->stop_with_error); /* Do not send error twice */ - mhd_assert (MHD_CONNECTION_REQ_RECV_FINISHED >= c->state); + mhd_assert (mhd_HTTP_STAGE_REQ_RECV_FINISHED >= c->stage); /* Discard most of the request data */ @@ -119,5 +119,5 @@ respond_with_error_len (struct MHD_Connection *c, return; } c->rp.response = err_res; - c->state = MHD_CONNECTION_START_REPLY; + c->stage = mhd_HTTP_STAGE_START_REPLY; } diff --git a/src/mhd2/stream_funcs.c b/src/mhd2/stream_funcs.c index 28fee317..e7826399 100644 --- a/src/mhd2/stream_funcs.c +++ b/src/mhd2/stream_funcs.c @@ -297,13 +297,13 @@ mhd_stream_get_no_space_err_status_code (struct MHD_Connection *restrict c, size_t opt_headers_size; size_t host_field_line_size; - mhd_assert (MHD_CONNECTION_REQ_LINE_RECEIVED < c->state); + mhd_assert (mhd_HTTP_STAGE_REQ_LINE_RECEIVED < c->stage); mhd_assert (MHD_PROC_RECV_HEADERS <= stage); mhd_assert ((0 == add_element_size) || (NULL != add_element)); c->rq.too_large = true; - if (MHD_CONNECTION_HEADERS_RECEIVED > c->state) + if (mhd_HTTP_STAGE_HEADERS_RECEIVED > c->stage) { mhd_assert (NULL != c->rq.field_lines.start); opt_headers_size = @@ -344,7 +344,7 @@ mhd_stream_get_no_space_err_status_code (struct MHD_Connection *restrict c, if (is_host_header) { const bool is_parsed = ! ( - (MHD_CONNECTION_HEADERS_RECEIVED > c->state) && + (mhd_HTTP_STAGE_HEADERS_RECEIVED > c->stage) && (add_element_size == c->read_buffer_offset) && (c->read_buffer == add_element) ); size_t actual_element_size; @@ -554,7 +554,7 @@ mhd_stream_finish_req_serving (struct MHD_Connection *restrict c, c->rp.response = NULL; c->conn_reuse = mhd_CONN_KEEPALIVE_POSSIBLE; - c->state = MHD_CONNECTION_INIT; + c->stage = mhd_HTTP_STAGE_INIT; c->event_loop_info = (0 == c->read_buffer_offset) ? MHD_EVENT_LOOP_INFO_RECV : MHD_EVENT_LOOP_INFO_PROCESS; @@ -733,7 +733,7 @@ mhd_conn_start_closing (struct MHD_Connection *restrict c, break; case mhd_SOCKET_ERR_REMT_DISCONN: close_hard = false; - end_code = (MHD_CONNECTION_INIT == c->state) ? + end_code = (mhd_HTTP_STAGE_INIT == c->stage) ? MHD_REQUEST_ENDED_COMPLETED_OK /* Not used */ : MHD_REQUEST_ENDED_CLIENT_ABORT; break; @@ -767,7 +767,7 @@ mhd_conn_start_closing (struct MHD_Connection *restrict c, break; case mhd_CONN_CLOSE_TIMEDOUT: - if (MHD_CONNECTION_INIT == c->state) + if (mhd_HTTP_STAGE_INIT == c->stage) { close_hard = false; end_code = MHD_REQUEST_ENDED_COMPLETED_OK; /* Not used */ @@ -806,7 +806,7 @@ mhd_conn_start_closing (struct MHD_Connection *restrict c, #ifdef MHD_UPGRADE_SUPPORT if (mhd_CONN_CLOSE_UPGRADE == reason) { - mhd_assert (MHD_CONNECTION_UPGRADING == c->state); + mhd_assert (mhd_HTTP_STAGE_UPGRADING == c->stage); c->event_loop_info = MHD_EVENT_LOOP_INFO_UPGRADED; } else @@ -817,7 +817,7 @@ mhd_conn_start_closing (struct MHD_Connection *restrict c, { /* Use abortive closing, send RST to remote to indicate a problem */ (void) mhd_socket_set_hard_close (c->sk.fd); - c->state = MHD_CONNECTION_PRE_CLOSING; + c->stage = mhd_HTTP_STAGE_PRE_CLOSING; c->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP; } else @@ -825,12 +825,12 @@ mhd_conn_start_closing (struct MHD_Connection *restrict c, if (mhd_socket_shut_wr (c->sk.fd) && (! c->sk.state.rmt_shut_wr)) { (void) 0; // TODO: start local lingering phase - c->state = MHD_CONNECTION_PRE_CLOSING; // TODO: start local lingering phase + c->stage = mhd_HTTP_STAGE_PRE_CLOSING; // TODO: start local lingering phase c->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP; // TODO: start local lingering phase } else { /* No need / not possible to linger */ - c->state = MHD_CONNECTION_PRE_CLOSING; + c->stage = mhd_HTTP_STAGE_PRE_CLOSING; c->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP; } } @@ -845,7 +845,7 @@ mhd_conn_start_closing (struct MHD_Connection *restrict c, #endif /* ! HAVE_LOG_FUNCTIONALITY */ #if 0 // TODO: notification callback - mhd_assert ((MHD_CONNECTION_INIT != c->state) || (! c->rq.app_aware)); + mhd_assert ((mhd_HTTP_STAGE_INIT != c->stage) || (! c->rq.app_aware)); if ( (NULL != d->notify_completed) && (c->rq.app_aware) ) d->notify_completed (d->notify_completed_cls, @@ -939,7 +939,7 @@ mhd_conn_pre_clean (struct MHD_Connection *restrict c) mhd_pool_destroy (c->pool); c->pool = NULL; - c->state = MHD_CONNECTION_CLOSED; + c->stage = mhd_HTTP_STAGE_CLOSED; #ifndef NDEBUG c->dbg.pre_cleaned = true; #endif diff --git a/src/mhd2/stream_process_reply.c b/src/mhd2/stream_process_reply.c index 685d1805..4898720d 100644 --- a/src/mhd2/stream_process_reply.c +++ b/src/mhd2/stream_process_reply.c @@ -892,7 +892,7 @@ mhd_stream_build_header_response (struct MHD_Connection *restrict c) "No memory in the pool for the reply headers."); return false; } - c->state = MHD_CONNECTION_HEADERS_SENDING; + c->stage = mhd_HTTP_STAGE_HEADERS_SENDING; return true; } @@ -978,7 +978,7 @@ mhd_stream_prep_unchunked_body (struct MHD_Connection *restrict c) if (0 == r->cntn_size) { /* 0-byte response is always ready */ - c->state = MHD_CONNECTION_FULL_REPLY_SENT; + c->stage = mhd_HTTP_STAGE_FULL_REPLY_SENT; return true; } @@ -1017,7 +1017,7 @@ mhd_stream_prep_unchunked_body (struct MHD_Connection *restrict c) mhd_assert (MHD_SIZE_UNKNOWN == r->cntn_size); mhd_assert (c->rp.props.end_by_closing); - c->state = MHD_CONNECTION_FULL_REPLY_SENT; + c->stage = mhd_HTTP_STAGE_FULL_REPLY_SENT; return true; } @@ -1093,7 +1093,7 @@ mhd_stream_prep_unchunked_body (struct MHD_Connection *restrict c) c->rp.rsp_cntn_read_pos = r->cntn_size; } - c->state = MHD_CONNECTION_UNCHUNKED_BODY_READY; + c->stage = mhd_HTTP_STAGE_UNCHUNKED_BODY_READY; return false; } @@ -1151,7 +1151,7 @@ mhd_stream_prep_chunked_body (struct MHD_Connection *restrict c) if ((0 == left_to_send) && (mhd_RESPONSE_CONTENT_DATA_CALLBACK != r->cntn_dtype)) { - c->state = MHD_CONNECTION_CHUNKED_BODY_SENT; + c->stage = mhd_HTTP_STAGE_CHUNKED_BODY_SENT; return true; } else if (mhd_RESPONSE_CONTENT_DATA_BUFFER == r->cntn_dtype) @@ -1185,7 +1185,7 @@ mhd_stream_prep_chunked_body (struct MHD_Connection *restrict c) if (mhd_DCC_ACTION_FINISH == c->rp.app_act.act) { mhd_assert (MHD_SIZE_UNKNOWN == r->cntn_size); - c->state = MHD_CONNECTION_CHUNKED_BODY_SENT; + c->stage = mhd_HTTP_STAGE_CHUNKED_BODY_SENT; return true; } @@ -1229,7 +1229,7 @@ mhd_stream_prep_chunked_body (struct MHD_Connection *restrict c) else c->rp.rsp_cntn_read_pos = r->cntn_size; - c->state = MHD_CONNECTION_CHUNKED_BODY_READY; + c->stage = mhd_HTTP_STAGE_CHUNKED_BODY_READY; return false; } @@ -1253,7 +1253,7 @@ prep_chunked_footer_inn (struct MHD_Connection *restrict c) // struct MHD_HTTP_Res_Header *pos; mhd_assert (c->rp.props.chunked); - mhd_assert (MHD_CONNECTION_CHUNKED_BODY_SENT == c->state); + mhd_assert (mhd_HTTP_STAGE_CHUNKED_BODY_SENT == c->stage); mhd_assert (NULL != c->rp.response); buf_size = mhd_stream_maximize_write_buffer (c); @@ -1313,6 +1313,6 @@ mhd_stream_prep_chunked_footer (struct MHD_Connection *restrict c) "No memory in the pool for the reply chunked footer."); return true; } - c->state = MHD_CONNECTION_FOOTERS_SENDING; + c->stage = mhd_HTTP_STAGE_FOOTERS_SENDING; return false; } diff --git a/src/mhd2/stream_process_request.c b/src/mhd2/stream_process_request.c index 9471814e..e6c7ea04 100644 --- a/src/mhd2/stream_process_request.c +++ b/src/mhd2/stream_process_request.c @@ -616,18 +616,18 @@ get_request_line_inner (struct MHD_Connection *restrict c) RFC 9112, section 2.2 */ const bool bare_cr_as_sp = ((! bare_cr_keep) && (-1 >= discp_lvl)); - mhd_assert (MHD_CONNECTION_INIT == c->state || \ - MHD_CONNECTION_REQ_LINE_RECEIVING == c->state); + mhd_assert (mhd_HTTP_STAGE_INIT == c->stage || \ + mhd_HTTP_STAGE_REQ_LINE_RECEIVING == c->stage); mhd_assert (NULL == c->rq.method || \ - MHD_CONNECTION_REQ_LINE_RECEIVING == c->state); + mhd_HTTP_STAGE_REQ_LINE_RECEIVING == c->stage); mhd_assert (mhd_HTTP_METHOD_NO_METHOD == c->rq.http_mthd || \ - MHD_CONNECTION_REQ_LINE_RECEIVING == c->state); + mhd_HTTP_STAGE_REQ_LINE_RECEIVING == c->stage); mhd_assert (mhd_HTTP_METHOD_NO_METHOD == c->rq.http_mthd || \ 0 != c->rq.hdrs.rq_line.proc_pos); if (0 == c->read_buffer_offset) { - mhd_assert (MHD_CONNECTION_INIT == c->state); + mhd_assert (mhd_HTTP_STAGE_INIT == c->stage); return false; /* No data to process */ } p = c->rq.hdrs.rq_line.proc_pos; @@ -641,7 +641,7 @@ get_request_line_inner (struct MHD_Connection *restrict c) /* Skip empty lines before the request line. See RFC 9112, section 2.2 */ bool is_empty_line; - mhd_assert (MHD_CONNECTION_INIT == c->state); + mhd_assert (mhd_HTTP_STAGE_INIT == c->stage); mhd_assert (NULL == c->rq.method); mhd_assert (NULL == c->rq.url); mhd_assert (0 == c->rq.url_len); @@ -692,7 +692,7 @@ get_request_line_inner (struct MHD_Connection *restrict c) } /* All empty lines are skipped */ - c->state = MHD_CONNECTION_REQ_LINE_RECEIVING; + c->stage = mhd_HTTP_STAGE_REQ_LINE_RECEIVING; /* Read and parse the request line */ mhd_assert (1 <= c->read_buffer_offset); @@ -871,7 +871,7 @@ get_request_line_inner (struct MHD_Connection *restrict c) - (size_t) (c->rq.version - read_buffer))) { - mhd_assert (MHD_CONNECTION_REQ_LINE_RECEIVING < c->state); + mhd_assert (mhd_HTTP_STAGE_REQ_LINE_RECEIVING < c->stage); return true; /* Unsupported / broken HTTP version */ } read_buffer[p] = 0; /* Zero terminate the HTTP version strings */ @@ -1232,7 +1232,7 @@ process_request_target (struct MHD_Connection *c) { size_t params_len; - mhd_assert (MHD_CONNECTION_REQ_LINE_RECEIVING == c->state); + mhd_assert (mhd_HTTP_STAGE_REQ_LINE_RECEIVING == c->stage); mhd_assert (NULL == c->rq.url); mhd_assert (0 == c->rq.url_len); mhd_assert (NULL != c->rq.hdrs.rq_line.rq_tgt); @@ -1282,7 +1282,7 @@ process_request_target (struct MHD_Connection *c) 0, NULL), ERR_RSP_MSG_REQUEST_TOO_BIG); - mhd_assert (MHD_CONNECTION_REQ_LINE_RECEIVING != c->state); + mhd_assert (mhd_HTTP_STAGE_REQ_LINE_RECEIVING != c->stage); return false; } @@ -1333,7 +1333,7 @@ send_redirect_fixed_rq_target (struct MHD_Connection *restrict c) size_t i; size_t o; - mhd_assert (MHD_CONNECTION_REQ_LINE_RECEIVING == c->state); + mhd_assert (mhd_HTTP_STAGE_REQ_LINE_RECEIVING == c->stage); mhd_assert (0 != c->rq.hdrs.rq_line.num_ws_in_uri); mhd_assert (c->rq.hdrs.rq_line.num_ws_in_uri <= \ c->rq.req_target_len); @@ -1428,10 +1428,10 @@ mhd_stream_get_request_line (struct MHD_Connection *restrict c) } return false; } - if (MHD_CONNECTION_REQ_LINE_RECEIVING < c->state) + if (mhd_HTTP_STAGE_REQ_LINE_RECEIVING < c->stage) return true; /* Error in the request */ - mhd_assert (MHD_CONNECTION_REQ_LINE_RECEIVING == c->state); + mhd_assert (mhd_HTTP_STAGE_REQ_LINE_RECEIVING == c->stage); mhd_assert (NULL == c->rq.url); mhd_assert (0 == c->rq.url_len); mhd_assert (NULL != c->rq.hdrs.rq_line.rq_tgt); @@ -1453,7 +1453,7 @@ mhd_stream_get_request_line (struct MHD_Connection *restrict c) if (! process_request_target (c)) return true; /* Error in processing */ - c->state = MHD_CONNECTION_REQ_LINE_RECEIVED; + c->stage = mhd_HTTP_STAGE_REQ_LINE_RECEIVED; return true; } @@ -1463,7 +1463,7 @@ mhd_stream_switch_to_rq_headers_proc (struct MHD_Connection *restrict c) { c->rq.field_lines.start = c->read_buffer; mhd_stream_reset_rq_hdr_proc_state (c); - c->state = MHD_CONNECTION_REQ_HEADERS_RECEIVING; + c->stage = mhd_HTTP_STAGE_REQ_HEADERS_RECEIVING; } @@ -1604,9 +1604,9 @@ get_req_header (struct MHD_Connection *restrict c, (void) process_footers; /* Unused parameter in non-debug and no messages */ - mhd_assert ((process_footers ? MHD_CONNECTION_FOOTERS_RECEIVING : \ - MHD_CONNECTION_REQ_HEADERS_RECEIVING) == \ - c->state); + mhd_assert ((process_footers ? mhd_HTTP_STAGE_FOOTERS_RECEIVING : \ + mhd_HTTP_STAGE_REQ_HEADERS_RECEIVING) == \ + c->stage); p = c->rq.hdrs.hdr.proc_pos; @@ -2033,9 +2033,9 @@ mhd_stream_get_request_headers (struct MHD_Connection *restrict c, struct MHD_String hdr_value; enum mhd_HdrLineReadRes res; - mhd_assert ((process_footers ? MHD_CONNECTION_FOOTERS_RECEIVING : \ - MHD_CONNECTION_REQ_HEADERS_RECEIVING) == \ - c->state); + mhd_assert ((process_footers ? mhd_HTTP_STAGE_FOOTERS_RECEIVING : \ + mhd_HTTP_STAGE_REQ_HEADERS_RECEIVING) == \ + c->stage); #ifndef NDEBUG hdr_name.cstr = NULL; @@ -2044,9 +2044,9 @@ mhd_stream_get_request_headers (struct MHD_Connection *restrict c, res = get_req_header (c, process_footers, &hdr_name, &hdr_value); if (MHD_HDR_LINE_READING_GOT_HEADER == res) { - mhd_assert ((process_footers ? MHD_CONNECTION_FOOTERS_RECEIVING : \ - MHD_CONNECTION_REQ_HEADERS_RECEIVING) == \ - c->state); + mhd_assert ((process_footers ? mhd_HTTP_STAGE_FOOTERS_RECEIVING : \ + mhd_HTTP_STAGE_REQ_HEADERS_RECEIVING) == \ + c->stage); mhd_assert (NULL != hdr_name.cstr); mhd_assert (NULL != hdr_value.cstr); /* Values must be zero-terminated and must not have binary zeros */ @@ -2093,29 +2093,29 @@ mhd_stream_get_request_headers (struct MHD_Connection *restrict c, else handle_req_footers_no_space (c, hdr_name.cstr, add_element_size); - mhd_assert (MHD_CONNECTION_FULL_REQ_RECEIVED < c->state); + mhd_assert (mhd_HTTP_STAGE_FULL_REQ_RECEIVED < c->stage); return true; } /* Reset processing state */ mhd_stream_reset_rq_hdr_proc_state (c); - mhd_assert ((process_footers ? MHD_CONNECTION_FOOTERS_RECEIVING : \ - MHD_CONNECTION_REQ_HEADERS_RECEIVING) == \ - c->state); + mhd_assert ((process_footers ? mhd_HTTP_STAGE_FOOTERS_RECEIVING : \ + mhd_HTTP_STAGE_REQ_HEADERS_RECEIVING) == \ + c->stage); /* Read the next header (field) line */ continue; } else if (MHD_HDR_LINE_READING_NEED_MORE_DATA == res) { - mhd_assert ((process_footers ? MHD_CONNECTION_FOOTERS_RECEIVING : \ - MHD_CONNECTION_REQ_HEADERS_RECEIVING) == \ - c->state); + mhd_assert ((process_footers ? mhd_HTTP_STAGE_FOOTERS_RECEIVING : \ + mhd_HTTP_STAGE_REQ_HEADERS_RECEIVING) == \ + c->stage); return false; } else if (MHD_HDR_LINE_READING_DATA_ERROR == res) { mhd_assert ((process_footers ? \ - MHD_CONNECTION_FOOTERS_RECEIVING : \ - MHD_CONNECTION_REQ_HEADERS_RECEIVING) < c->state); + mhd_HTTP_STAGE_FOOTERS_RECEIVING : \ + mhd_HTTP_STAGE_REQ_HEADERS_RECEIVING) < c->stage); mhd_assert (c->stop_with_error); mhd_assert (c->discard_request); return true; @@ -2184,7 +2184,7 @@ mhd_stream_get_request_headers (struct MHD_Connection *restrict c, (size_t) ((c->read_buffer - c->rq.field_lines.start) - 1); if ('\r' == *(c->read_buffer - 2)) c->rq.field_lines.size--; - c->state = MHD_CONNECTION_HEADERS_RECEIVED; + c->stage = mhd_HTTP_STAGE_HEADERS_RECEIVED; if (mhd_BUF_INC_SIZE > c->read_buffer_size) { @@ -2215,7 +2215,7 @@ mhd_stream_get_request_headers (struct MHD_Connection *restrict c, } } else - c->state = MHD_CONNECTION_FOOTERS_RECEIVED; + c->stage = mhd_HTTP_STAGE_FOOTERS_RECEIVED; return true; } @@ -2828,7 +2828,7 @@ mhd_stream_parse_request_headers (struct MHD_Connection *restrict c) c->conn_reuse = mhd_CONN_MUST_CLOSE; /* Framing could be incorrect */ } - c->state = MHD_CONNECTION_HEADERS_PROCESSED; + c->stage = mhd_HTTP_STAGE_HEADERS_PROCESSED; return; } @@ -2844,8 +2844,8 @@ static MHD_FN_PAR_NONNULL_ALL_ bool need_100_continue (struct MHD_Connection *restrict c) { mhd_assert (MHD_HTTP_VERSION_IS_SUPPORTED (c->rq.http_ver)); - mhd_assert (MHD_CONNECTION_HEADERS_PROCESSED <= c->state); - mhd_assert (MHD_CONNECTION_BODY_RECEIVING > c->state); + mhd_assert (mhd_HTTP_STAGE_HEADERS_PROCESSED <= c->stage); + mhd_assert (mhd_HTTP_STAGE_BODY_RECEIVING > c->stage); if (! c->rq.have_expect_100) return false; /* "100 Continue" has not been requested by the client */ @@ -2958,7 +2958,7 @@ mhd_stream_call_app_request_cb (struct MHD_Connection *restrict c) { case mhd_ACTION_RESPONSE: c->rp.response = c->rq.app_act.head_act.data.response; - c->state = MHD_CONNECTION_REQ_RECV_FINISHED; + c->stage = mhd_HTTP_STAGE_REQ_RECV_FINISHED; return true; case mhd_ACTION_UPLOAD: if (0 != c->rq.cntn.cntn_size) @@ -2967,33 +2967,33 @@ mhd_stream_call_app_request_cb (struct MHD_Connection *restrict c) return true; if (need_100_continue (c)) { - c->state = MHD_CONNECTION_CONTINUE_SENDING; + c->stage = mhd_HTTP_STAGE_CONTINUE_SENDING; return true; } - c->state = MHD_CONNECTION_BODY_RECEIVING; + c->stage = mhd_HTTP_STAGE_BODY_RECEIVING; return (0 != c->read_buffer_offset); } - c->state = MHD_CONNECTION_FULL_REQ_RECEIVED; + c->stage = mhd_HTTP_STAGE_FULL_REQ_RECEIVED; return true; #ifdef HAVE_POST_PARSER case mhd_ACTION_POST_PARSE: if (0 == c->rq.cntn.cntn_size) { c->rq.u_proc.post.parse_result = MHD_POST_PARSE_RES_REQUEST_EMPTY; - c->state = MHD_CONNECTION_FULL_REQ_RECEIVED; + c->stage = mhd_HTTP_STAGE_FULL_REQ_RECEIVED; return true; } if (! mhd_stream_prepare_for_post_parse (c)) { - mhd_assert (MHD_CONNECTION_FOOTERS_RECEIVED < c->state); + mhd_assert (mhd_HTTP_STAGE_FOOTERS_RECEIVED < c->stage); return true; } if (need_100_continue (c)) { - c->state = MHD_CONNECTION_CONTINUE_SENDING; + c->stage = mhd_HTTP_STAGE_CONTINUE_SENDING; return true; } - c->state = MHD_CONNECTION_BODY_RECEIVING; + c->stage = mhd_HTTP_STAGE_BODY_RECEIVING; return true; #endif /* HAVE_POST_PARSER */ case mhd_ACTION_SUSPEND: @@ -3002,7 +3002,7 @@ mhd_stream_call_app_request_cb (struct MHD_Connection *restrict c) #ifdef MHD_UPGRADE_SUPPORT case mhd_ACTION_UPGRADE: mhd_assert (0 == c->rq.cntn.cntn_size); - c->state = MHD_CONNECTION_UPGRADE_HEADERS_SENDING; + c->stage = mhd_HTTP_STAGE_UPGRADE_HEADERS_SENDING; return false; #endif /* MHD_UPGRADE_SUPPORT */ case mhd_ACTION_ABORT: @@ -3052,7 +3052,7 @@ mhd_stream_process_upload_action (struct MHD_Connection *restrict c, { case mhd_UPLOAD_ACTION_RESPONSE: c->rp.response = c->rq.app_act.upl_act.data.response; - c->state = MHD_CONNECTION_REQ_RECV_FINISHED; + c->stage = mhd_HTTP_STAGE_REQ_RECV_FINISHED; return true; case mhd_UPLOAD_ACTION_CONTINUE: memset (&(c->rq.app_act.upl_act), 0, sizeof(c->rq.app_act.upl_act)); @@ -3064,8 +3064,8 @@ mhd_stream_process_upload_action (struct MHD_Connection *restrict c, case mhd_UPLOAD_ACTION_UPGRADE: mhd_assert (c->rq.cntn.recv_size == c->rq.cntn.cntn_size); mhd_assert (! c->rq.have_chunked_upload || \ - MHD_CONNECTION_FULL_REQ_RECEIVED == c->state); - c->state = MHD_CONNECTION_UPGRADE_HEADERS_SENDING; + mhd_HTTP_STAGE_FULL_REQ_RECEIVED == c->stage); + c->stage = mhd_HTTP_STAGE_UPGRADE_HEADERS_SENDING; return false; #endif /* MHD_UPGRADE_SUPPORT */ case mhd_UPLOAD_ACTION_ABORT: @@ -3265,7 +3265,7 @@ process_request_chunked_body (struct MHD_Connection *restrict c) if (0 == chunk_size) { /* The final (termination) chunk */ c->rq.cntn.cntn_size = c->rq.cntn.recv_size; - c->state = MHD_CONNECTION_BODY_RECEIVED; + c->stage = mhd_HTTP_STAGE_BODY_RECEIVED; state_updated = true; break; } @@ -3302,8 +3302,8 @@ process_request_chunked_body (struct MHD_Connection *restrict c) // TODO: support one chunk in-place processing? mhd_assert ((0 == cntn_data_ready) || \ (MHD_POST_PARSE_RES_OK != c->rq.u_proc.post.parse_result) || \ - (MHD_CONNECTION_BODY_RECEIVING != c->state)); - if (MHD_CONNECTION_BODY_RECEIVING != c->state) + (mhd_HTTP_STAGE_BODY_RECEIVING != c->stage)); + if (mhd_HTTP_STAGE_BODY_RECEIVING != c->stage) c->discard_request = true; c->rq.cntn.recv_size += size_provided; } @@ -3436,15 +3436,15 @@ process_request_nonchunked_body (struct MHD_Connection *restrict c) c->read_buffer); mhd_assert ((0 == size_provided) || \ (MHD_POST_PARSE_RES_OK != c->rq.u_proc.post.parse_result) || \ - (MHD_CONNECTION_BODY_RECEIVING != c->state)); - if (MHD_CONNECTION_BODY_RECEIVING != c->state) + (mhd_HTTP_STAGE_BODY_RECEIVING != c->stage)); + if (mhd_HTTP_STAGE_BODY_RECEIVING != c->stage) c->discard_request = true; read_buf_reuse = true; c->rq.cntn.proc_size += cntn_data_ready; if (c->rq.cntn.recv_size == c->rq.cntn.cntn_size) { - c->state = MHD_CONNECTION_FULL_REQ_RECEIVED; + c->stage = mhd_HTTP_STAGE_FULL_REQ_RECEIVED; state_updated = true; } } @@ -3464,7 +3464,7 @@ process_request_nonchunked_body (struct MHD_Connection *restrict c) read_buf_reuse = true; if (c->rq.cntn.recv_size == c->rq.cntn.cntn_size) { - c->state = MHD_CONNECTION_FULL_REQ_RECEIVED; + c->stage = mhd_HTTP_STAGE_FULL_REQ_RECEIVED; state_updated = true; } } @@ -3568,7 +3568,7 @@ mhd_stream_process_req_recv_finished (struct MHD_Connection *restrict c) if (c->rq.cntn.cntn_size != c->rq.cntn.proc_size) c->discard_request = true; mhd_assert (NULL != c->rp.response); - c->state = MHD_CONNECTION_START_REPLY; + c->stage = mhd_HTTP_STAGE_START_REPLY; return true; } @@ -3629,24 +3629,24 @@ handle_recv_no_space (struct MHD_Connection *c, { mhd_assert (MHD_PROC_RECV_INIT <= stage); mhd_assert (MHD_PROC_RECV_FOOTERS >= stage); - mhd_assert (MHD_CONNECTION_FULL_REQ_RECEIVED > c->state); + mhd_assert (mhd_HTTP_STAGE_FULL_REQ_RECEIVED > c->stage); mhd_assert ((MHD_PROC_RECV_INIT != stage) || \ - (MHD_CONNECTION_INIT == c->state)); + (mhd_HTTP_STAGE_INIT == c->stage)); mhd_assert ((MHD_PROC_RECV_METHOD != stage) || \ - (MHD_CONNECTION_REQ_LINE_RECEIVING == c->state)); + (mhd_HTTP_STAGE_REQ_LINE_RECEIVING == c->stage)); mhd_assert ((MHD_PROC_RECV_URI != stage) || \ - (MHD_CONNECTION_REQ_LINE_RECEIVING == c->state)); + (mhd_HTTP_STAGE_REQ_LINE_RECEIVING == c->stage)); mhd_assert ((MHD_PROC_RECV_HTTPVER != stage) || \ - (MHD_CONNECTION_REQ_LINE_RECEIVING == c->state)); + (mhd_HTTP_STAGE_REQ_LINE_RECEIVING == c->stage)); mhd_assert ((MHD_PROC_RECV_HEADERS != stage) || \ - (MHD_CONNECTION_REQ_HEADERS_RECEIVING == c->state)); + (mhd_HTTP_STAGE_REQ_HEADERS_RECEIVING == c->stage)); mhd_assert (MHD_PROC_RECV_COOKIE != stage); /* handle_req_cookie_no_space() must be called directly */ mhd_assert ((MHD_PROC_RECV_BODY_NORMAL != stage) || \ - (MHD_CONNECTION_BODY_RECEIVING == c->state)); + (mhd_HTTP_STAGE_BODY_RECEIVING == c->stage)); mhd_assert ((MHD_PROC_RECV_BODY_CHUNKED != stage) || \ - (MHD_CONNECTION_BODY_RECEIVING == c->state)); + (mhd_HTTP_STAGE_BODY_RECEIVING == c->stage)); mhd_assert ((MHD_PROC_RECV_FOOTERS != stage) || \ - (MHD_CONNECTION_FOOTERS_RECEIVING == c->state)); + (mhd_HTTP_STAGE_FOOTERS_RECEIVING == c->stage)); mhd_assert ((MHD_PROC_RECV_BODY_NORMAL != stage) || \ (! c->rq.have_chunked_upload)); mhd_assert ((MHD_PROC_RECV_BODY_CHUNKED != stage) || \ @@ -3844,7 +3844,7 @@ mhd_stream_check_and_grow_read_buffer_space (struct MHD_Connection *restrict c) c->read_buffer_size); if ((rbuff_grow_desired) && - (MHD_CONNECTION_BODY_RECEIVING == c->state)) + (mhd_HTTP_STAGE_BODY_RECEIVING == c->stage)) { if (! c->rq.have_chunked_upload) { @@ -3892,12 +3892,12 @@ mhd_stream_check_and_grow_read_buffer_space (struct MHD_Connection *restrict c) { enum MHD_ProcRecvDataStage stage; - switch (c->state) + switch (c->stage) { - case MHD_CONNECTION_INIT: + case mhd_HTTP_STAGE_INIT: stage = MHD_PROC_RECV_INIT; break; - case MHD_CONNECTION_REQ_LINE_RECEIVING: + case mhd_HTTP_STAGE_REQ_LINE_RECEIVING: if (mhd_HTTP_METHOD_NO_METHOD == c->rq.http_mthd) stage = MHD_PROC_RECV_METHOD; else if (0 == c->rq.req_target_len) @@ -3905,41 +3905,41 @@ mhd_stream_check_and_grow_read_buffer_space (struct MHD_Connection *restrict c) else stage = MHD_PROC_RECV_HTTPVER; break; - case MHD_CONNECTION_REQ_HEADERS_RECEIVING: + case mhd_HTTP_STAGE_REQ_HEADERS_RECEIVING: stage = MHD_PROC_RECV_HEADERS; break; - case MHD_CONNECTION_BODY_RECEIVING: + case mhd_HTTP_STAGE_BODY_RECEIVING: stage = c->rq.have_chunked_upload ? MHD_PROC_RECV_BODY_CHUNKED : MHD_PROC_RECV_BODY_NORMAL; break; - case MHD_CONNECTION_FOOTERS_RECEIVING: + case mhd_HTTP_STAGE_FOOTERS_RECEIVING: stage = MHD_PROC_RECV_FOOTERS; break; - case MHD_CONNECTION_REQ_LINE_RECEIVED: - case MHD_CONNECTION_HEADERS_RECEIVED: - case MHD_CONNECTION_HEADERS_PROCESSED: - case MHD_CONNECTION_CONTINUE_SENDING: - case MHD_CONNECTION_BODY_RECEIVED: - case MHD_CONNECTION_FOOTERS_RECEIVED: - case MHD_CONNECTION_FULL_REQ_RECEIVED: - case MHD_CONNECTION_REQ_RECV_FINISHED: - case MHD_CONNECTION_START_REPLY: - case MHD_CONNECTION_HEADERS_SENDING: - case MHD_CONNECTION_HEADERS_SENT: - case MHD_CONNECTION_UNCHUNKED_BODY_UNREADY: - case MHD_CONNECTION_UNCHUNKED_BODY_READY: - case MHD_CONNECTION_CHUNKED_BODY_UNREADY: - case MHD_CONNECTION_CHUNKED_BODY_READY: - case MHD_CONNECTION_CHUNKED_BODY_SENT: - case MHD_CONNECTION_FOOTERS_SENDING: - case MHD_CONNECTION_FULL_REPLY_SENT: - case MHD_CONNECTION_PRE_CLOSING: - case MHD_CONNECTION_CLOSED: + case mhd_HTTP_STAGE_REQ_LINE_RECEIVED: + case mhd_HTTP_STAGE_HEADERS_RECEIVED: + case mhd_HTTP_STAGE_HEADERS_PROCESSED: + case mhd_HTTP_STAGE_CONTINUE_SENDING: + case mhd_HTTP_STAGE_BODY_RECEIVED: + case mhd_HTTP_STAGE_FOOTERS_RECEIVED: + case mhd_HTTP_STAGE_FULL_REQ_RECEIVED: + case mhd_HTTP_STAGE_REQ_RECV_FINISHED: + case mhd_HTTP_STAGE_START_REPLY: + case mhd_HTTP_STAGE_HEADERS_SENDING: + case mhd_HTTP_STAGE_HEADERS_SENT: + case mhd_HTTP_STAGE_UNCHUNKED_BODY_UNREADY: + case mhd_HTTP_STAGE_UNCHUNKED_BODY_READY: + case mhd_HTTP_STAGE_CHUNKED_BODY_UNREADY: + case mhd_HTTP_STAGE_CHUNKED_BODY_READY: + case mhd_HTTP_STAGE_CHUNKED_BODY_SENT: + case mhd_HTTP_STAGE_FOOTERS_SENDING: + case mhd_HTTP_STAGE_FULL_REPLY_SENT: + case mhd_HTTP_STAGE_PRE_CLOSING: + case mhd_HTTP_STAGE_CLOSED: #ifdef MHD_UPGRADE_SUPPORT - case MHD_CONNECTION_UPGRADE_HEADERS_SENDING: - case MHD_CONNECTION_UPGRADING: - case MHD_CONNECTION_UPGRADED: - case MHD_CONNECTION_UPGRADED_CLEANING: + case mhd_HTTP_STAGE_UPGRADE_HEADERS_SENDING: + case mhd_HTTP_STAGE_UPGRADING: + case mhd_HTTP_STAGE_UPGRADED: + case mhd_HTTP_STAGE_UPGRADED_CLEANING: #endif /* MHD_UPGRADE_SUPPORT */ default: mhd_assert (0); diff --git a/src/mhd2/stream_process_states.c b/src/mhd2/stream_process_states.c index 29d1b2ae..84ed66ab 100644 --- a/src/mhd2/stream_process_states.c +++ b/src/mhd2/stream_process_states.c @@ -73,110 +73,110 @@ mhd_conn_event_loop_state_update (struct MHD_Connection *restrict c) } } #endif /* HTTPS_SUPPORT */ - switch (c->state) + switch (c->stage) { - case MHD_CONNECTION_INIT: - case MHD_CONNECTION_REQ_LINE_RECEIVING: + case mhd_HTTP_STAGE_INIT: + case mhd_HTTP_STAGE_REQ_LINE_RECEIVING: c->event_loop_info = MHD_EVENT_LOOP_INFO_RECV; break; - case MHD_CONNECTION_REQ_LINE_RECEIVED: + case mhd_HTTP_STAGE_REQ_LINE_RECEIVED: mhd_assert (0 && "Impossible value"); MHD_UNREACHABLE_; break; - case MHD_CONNECTION_REQ_HEADERS_RECEIVING: + case mhd_HTTP_STAGE_REQ_HEADERS_RECEIVING: c->event_loop_info = MHD_EVENT_LOOP_INFO_RECV; break; - case MHD_CONNECTION_HEADERS_RECEIVED: - case MHD_CONNECTION_HEADERS_PROCESSED: + case mhd_HTTP_STAGE_HEADERS_RECEIVED: + case mhd_HTTP_STAGE_HEADERS_PROCESSED: mhd_assert (0 && "Impossible value"); MHD_UNREACHABLE_; break; - case MHD_CONNECTION_CONTINUE_SENDING: + case mhd_HTTP_STAGE_CONTINUE_SENDING: c->event_loop_info = MHD_EVENT_LOOP_INFO_SEND; break; - case MHD_CONNECTION_BODY_RECEIVING: + case mhd_HTTP_STAGE_BODY_RECEIVING: c->event_loop_info = MHD_EVENT_LOOP_INFO_RECV; break; - case MHD_CONNECTION_BODY_RECEIVED: + case mhd_HTTP_STAGE_BODY_RECEIVED: mhd_assert (0 && "Impossible value"); MHD_UNREACHABLE_; break; - case MHD_CONNECTION_FOOTERS_RECEIVING: + case mhd_HTTP_STAGE_FOOTERS_RECEIVING: c->event_loop_info = MHD_EVENT_LOOP_INFO_RECV; break; - case MHD_CONNECTION_FOOTERS_RECEIVED: + case mhd_HTTP_STAGE_FOOTERS_RECEIVED: mhd_assert (0 && "Impossible value"); MHD_UNREACHABLE_; break; - case MHD_CONNECTION_FULL_REQ_RECEIVED: + case mhd_HTTP_STAGE_FULL_REQ_RECEIVED: mhd_assert (0 && "Should not be possible"); c->event_loop_info = MHD_EVENT_LOOP_INFO_PROCESS; break; - case MHD_CONNECTION_REQ_RECV_FINISHED: + case mhd_HTTP_STAGE_REQ_RECV_FINISHED: mhd_assert (0 && "Impossible value"); MHD_UNREACHABLE_; break; - case MHD_CONNECTION_START_REPLY: + case mhd_HTTP_STAGE_START_REPLY: mhd_assert (0 && "Impossible value"); MHD_UNREACHABLE_; break; - case MHD_CONNECTION_HEADERS_SENDING: + case mhd_HTTP_STAGE_HEADERS_SENDING: /* headers in buffer, keep writing */ c->event_loop_info = MHD_EVENT_LOOP_INFO_SEND; break; - case MHD_CONNECTION_HEADERS_SENT: + case mhd_HTTP_STAGE_HEADERS_SENT: mhd_assert (0 && "Impossible value"); MHD_UNREACHABLE_; break; #ifdef MHD_UPGRADE_SUPPORT - case MHD_CONNECTION_UPGRADE_HEADERS_SENDING: + case mhd_HTTP_STAGE_UPGRADE_HEADERS_SENDING: c->event_loop_info = MHD_EVENT_LOOP_INFO_SEND; break; #endif /* MHD_UPGRADE_SUPPORT */ - case MHD_CONNECTION_UNCHUNKED_BODY_UNREADY: + case mhd_HTTP_STAGE_UNCHUNKED_BODY_UNREADY: mhd_assert (0 && "Should not be possible"); c->event_loop_info = MHD_EVENT_LOOP_INFO_PROCESS; break; - case MHD_CONNECTION_UNCHUNKED_BODY_READY: + case mhd_HTTP_STAGE_UNCHUNKED_BODY_READY: c->event_loop_info = MHD_EVENT_LOOP_INFO_SEND; break; - case MHD_CONNECTION_CHUNKED_BODY_UNREADY: + case mhd_HTTP_STAGE_CHUNKED_BODY_UNREADY: mhd_assert (0 && "Should not be possible"); c->event_loop_info = MHD_EVENT_LOOP_INFO_PROCESS; break; - case MHD_CONNECTION_CHUNKED_BODY_READY: + case mhd_HTTP_STAGE_CHUNKED_BODY_READY: c->event_loop_info = MHD_EVENT_LOOP_INFO_SEND; break; - case MHD_CONNECTION_CHUNKED_BODY_SENT: + case mhd_HTTP_STAGE_CHUNKED_BODY_SENT: mhd_assert (0 && "Impossible value"); MHD_UNREACHABLE_; break; - case MHD_CONNECTION_FOOTERS_SENDING: + case mhd_HTTP_STAGE_FOOTERS_SENDING: c->event_loop_info = MHD_EVENT_LOOP_INFO_SEND; break; - case MHD_CONNECTION_FULL_REPLY_SENT: + case mhd_HTTP_STAGE_FULL_REPLY_SENT: mhd_assert (0 && "Impossible value"); MHD_UNREACHABLE_; break; #ifdef MHD_UPGRADE_SUPPORT - case MHD_CONNECTION_UPGRADING: + case mhd_HTTP_STAGE_UPGRADING: mhd_assert (0 && "Impossible value"); MHD_UNREACHABLE_; break; - case MHD_CONNECTION_UPGRADED: + case mhd_HTTP_STAGE_UPGRADED: mhd_assert (0 && "Should not be possible"); c->event_loop_info = MHD_EVENT_LOOP_INFO_UPGRADED; break; - case MHD_CONNECTION_UPGRADED_CLEANING: + case mhd_HTTP_STAGE_UPGRADED_CLEANING: mhd_assert (0 && "Should be unreachable"); c->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP; break; #endif /* MHD_UPGRADE_SUPPORT */ - case MHD_CONNECTION_PRE_CLOSING: + case mhd_HTTP_STAGE_PRE_CLOSING: mhd_assert (0 && "Should be unreachable"); c->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP; break; - case MHD_CONNECTION_CLOSED: + case mhd_HTTP_STAGE_CLOSED: mhd_assert (0 && "Should be unreachable"); c->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP; break; @@ -243,12 +243,12 @@ mhd_conn_process_data (struct MHD_Connection *restrict c) /* 'daemon' is not used if epoll is not available and asserts are disabled */ (void) d; /* Mute compiler warning */ - if ((c->sk.state.rmt_shut_wr) && (MHD_CONNECTION_START_REPLY > c->state)) + if ((c->sk.state.rmt_shut_wr) && (mhd_HTTP_STAGE_START_REPLY > c->stage)) { if (0 == c->read_buffer_offset) { /* Read buffer is empty, connection state is actual */ mhd_conn_start_closing (c, - (MHD_CONNECTION_INIT == c->state) ? + (mhd_HTTP_STAGE_INIT == c->stage) ? mhd_CONN_CLOSE_HTTP_COMPLETED : mhd_CONN_CLOSE_CLIENT_SHUTDOWN_EARLY, NULL); @@ -291,57 +291,57 @@ mhd_conn_process_data (struct MHD_Connection *restrict c) #ifdef HTTPS_SUPPORT // TODO: support TLS, handshake #endif /* HTTPS_SUPPORT */ - switch (c->state) + switch (c->stage) { - case MHD_CONNECTION_INIT: - case MHD_CONNECTION_REQ_LINE_RECEIVING: + case mhd_HTTP_STAGE_INIT: + case mhd_HTTP_STAGE_REQ_LINE_RECEIVING: if (mhd_stream_get_request_line (c)) { - mhd_assert (MHD_CONNECTION_REQ_LINE_RECEIVING < c->state); + mhd_assert (mhd_HTTP_STAGE_REQ_LINE_RECEIVING < c->stage); mhd_assert ((MHD_HTTP_VERSION_IS_SUPPORTED (c->rq.http_ver)) \ || (c->discard_request)); continue; } - mhd_assert (MHD_CONNECTION_REQ_LINE_RECEIVING >= c->state); + mhd_assert (mhd_HTTP_STAGE_REQ_LINE_RECEIVING >= c->stage); break; - case MHD_CONNECTION_REQ_LINE_RECEIVED: + case mhd_HTTP_STAGE_REQ_LINE_RECEIVED: mhd_stream_switch_to_rq_headers_proc (c); - mhd_assert (MHD_CONNECTION_REQ_LINE_RECEIVED != c->state); + mhd_assert (mhd_HTTP_STAGE_REQ_LINE_RECEIVED != c->stage); continue; - case MHD_CONNECTION_REQ_HEADERS_RECEIVING: + case mhd_HTTP_STAGE_REQ_HEADERS_RECEIVING: if (mhd_stream_get_request_headers (c, false)) { - mhd_assert (MHD_CONNECTION_REQ_HEADERS_RECEIVING < c->state); - mhd_assert ((MHD_CONNECTION_HEADERS_RECEIVED == c->state) || \ + mhd_assert (mhd_HTTP_STAGE_REQ_HEADERS_RECEIVING < c->stage); + mhd_assert ((mhd_HTTP_STAGE_HEADERS_RECEIVED == c->stage) || \ (c->discard_request)); continue; } - mhd_assert (MHD_CONNECTION_REQ_HEADERS_RECEIVING == c->state); + mhd_assert (mhd_HTTP_STAGE_REQ_HEADERS_RECEIVING == c->stage); break; - case MHD_CONNECTION_HEADERS_RECEIVED: + case mhd_HTTP_STAGE_HEADERS_RECEIVED: mhd_stream_parse_request_headers (c); - mhd_assert (c->state != MHD_CONNECTION_HEADERS_RECEIVED); + mhd_assert (c->stage != mhd_HTTP_STAGE_HEADERS_RECEIVED); continue; - case MHD_CONNECTION_HEADERS_PROCESSED: + case mhd_HTTP_STAGE_HEADERS_PROCESSED: if (mhd_stream_call_app_request_cb (c)) { - mhd_assert (MHD_CONNECTION_HEADERS_PROCESSED < c->state); + mhd_assert (mhd_HTTP_STAGE_HEADERS_PROCESSED < c->stage); continue; } // TODO: add assert break; - case MHD_CONNECTION_CONTINUE_SENDING: + case mhd_HTTP_STAGE_CONTINUE_SENDING: if (c->continue_message_write_offset == mhd_SSTR_LEN (mdh_HTTP_1_1_100_CONTINUE_REPLY)) { #ifdef MHD_UPGRADE_SUPPORT c->rp.sent_100_cntn = true; #endif /* MHD_UPGRADE_SUPPORT */ - c->state = MHD_CONNECTION_BODY_RECEIVING; + c->stage = mhd_HTTP_STAGE_BODY_RECEIVING; continue; } break; - case MHD_CONNECTION_BODY_RECEIVING: + case mhd_HTTP_STAGE_BODY_RECEIVING: mhd_assert (c->rq.cntn.recv_size < c->rq.cntn.cntn_size); mhd_assert (! c->discard_request); mhd_assert (NULL == c->rp.response); @@ -353,7 +353,7 @@ mhd_conn_process_data (struct MHD_Connection *restrict c) mhd_assert (! c->discard_request); mhd_assert (NULL == c->rp.response); break; - case MHD_CONNECTION_BODY_RECEIVED: + case mhd_HTTP_STAGE_BODY_RECEIVED: mhd_assert (! c->discard_request); mhd_assert (NULL == c->rp.response); mhd_assert (c->rq.have_chunked_upload); @@ -361,97 +361,97 @@ mhd_conn_process_data (struct MHD_Connection *restrict c) c->rq.num_cr_sp_replaced = 0; c->rq.skipped_broken_lines = 0; mhd_stream_reset_rq_hdr_proc_state (c); - c->state = MHD_CONNECTION_FOOTERS_RECEIVING; + c->stage = mhd_HTTP_STAGE_FOOTERS_RECEIVING; continue; - case MHD_CONNECTION_FOOTERS_RECEIVING: + case mhd_HTTP_STAGE_FOOTERS_RECEIVING: mhd_assert (c->rq.have_chunked_upload); if (mhd_stream_get_request_headers (c, true)) { - mhd_assert (MHD_CONNECTION_FOOTERS_RECEIVING < c->state); - mhd_assert ((MHD_CONNECTION_FOOTERS_RECEIVED == c->state) || \ + mhd_assert (mhd_HTTP_STAGE_FOOTERS_RECEIVING < c->stage); + mhd_assert ((mhd_HTTP_STAGE_FOOTERS_RECEIVED == c->stage) || \ (c->discard_request)); continue; } - mhd_assert (MHD_CONNECTION_FOOTERS_RECEIVING == c->state); + mhd_assert (mhd_HTTP_STAGE_FOOTERS_RECEIVING == c->stage); break; - case MHD_CONNECTION_FOOTERS_RECEIVED: + case mhd_HTTP_STAGE_FOOTERS_RECEIVED: mhd_assert (c->rq.have_chunked_upload); - c->state = MHD_CONNECTION_FULL_REQ_RECEIVED; + c->stage = mhd_HTTP_STAGE_FULL_REQ_RECEIVED; continue; - case MHD_CONNECTION_FULL_REQ_RECEIVED: + case mhd_HTTP_STAGE_FULL_REQ_RECEIVED: if (mhd_stream_call_app_final_upload_cb (c)) { - mhd_assert (MHD_CONNECTION_FOOTERS_RECEIVING != c->state); + mhd_assert (mhd_HTTP_STAGE_FOOTERS_RECEIVING != c->stage); continue; } break; - case MHD_CONNECTION_REQ_RECV_FINISHED: + case mhd_HTTP_STAGE_REQ_RECV_FINISHED: if (mhd_stream_process_req_recv_finished (c)) continue; break; // TODO: add stage for setup and full request buffers cleanup - case MHD_CONNECTION_START_REPLY: + case mhd_HTTP_STAGE_START_REPLY: mhd_assert (NULL != c->rp.response); mhd_stream_switch_from_recv_to_send (c); if (! mhd_stream_build_header_response (c)) continue; - mhd_assert (MHD_CONNECTION_START_REPLY != c->state); + mhd_assert (mhd_HTTP_STAGE_START_REPLY != c->stage); break; - case MHD_CONNECTION_HEADERS_SENDING: + case mhd_HTTP_STAGE_HEADERS_SENDING: /* no default action, wait for sending all the headers */ break; - case MHD_CONNECTION_HEADERS_SENT: + case mhd_HTTP_STAGE_HEADERS_SENT: if (c->rp.props.send_reply_body) { if (c->rp.props.chunked) - c->state = MHD_CONNECTION_CHUNKED_BODY_UNREADY; + c->stage = mhd_HTTP_STAGE_CHUNKED_BODY_UNREADY; else - c->state = MHD_CONNECTION_UNCHUNKED_BODY_UNREADY; + c->stage = mhd_HTTP_STAGE_UNCHUNKED_BODY_UNREADY; } else - c->state = MHD_CONNECTION_FULL_REPLY_SENT; + c->stage = mhd_HTTP_STAGE_FULL_REPLY_SENT; continue; #ifdef MHD_UPGRADE_SUPPORT - case MHD_CONNECTION_UPGRADE_HEADERS_SENDING: + case mhd_HTTP_STAGE_UPGRADE_HEADERS_SENDING: if (! mhd_upgrade_try_start_upgrading (c)) break; continue; #endif /* MHD_UPGRADE_SUPPORT */ - case MHD_CONNECTION_UNCHUNKED_BODY_READY: + case mhd_HTTP_STAGE_UNCHUNKED_BODY_READY: mhd_assert (c->rp.props.send_reply_body); mhd_assert (! c->rp.props.chunked); /* nothing to do here, send the data */ break; - case MHD_CONNECTION_UNCHUNKED_BODY_UNREADY: + case mhd_HTTP_STAGE_UNCHUNKED_BODY_UNREADY: mhd_assert (c->rp.props.send_reply_body); mhd_assert (! c->rp.props.chunked); if (0 == c->rp.response->cntn_size) { /* a shortcut */ - c->state = MHD_CONNECTION_FULL_REPLY_SENT; + c->stage = mhd_HTTP_STAGE_FULL_REPLY_SENT; continue; } if (mhd_stream_prep_unchunked_body (c)) continue; break; - case MHD_CONNECTION_CHUNKED_BODY_READY: + case mhd_HTTP_STAGE_CHUNKED_BODY_READY: mhd_assert (c->rp.props.send_reply_body); mhd_assert (c->rp.props.chunked); /* nothing to do here */ break; - case MHD_CONNECTION_CHUNKED_BODY_UNREADY: + case mhd_HTTP_STAGE_CHUNKED_BODY_UNREADY: mhd_assert (c->rp.props.send_reply_body); mhd_assert (c->rp.props.chunked); if ( (0 == c->rp.response->cntn_size) || (c->rp.rsp_cntn_read_pos == c->rp.response->cntn_size) ) { - c->state = MHD_CONNECTION_CHUNKED_BODY_SENT; + c->stage = mhd_HTTP_STAGE_CHUNKED_BODY_SENT; continue; } if (mhd_stream_prep_chunked_body (c)) continue; break; - case MHD_CONNECTION_CHUNKED_BODY_SENT: + case mhd_HTTP_STAGE_CHUNKED_BODY_SENT: mhd_assert (c->rp.props.send_reply_body); mhd_assert (c->rp.props.chunked); mhd_assert (c->write_buffer_send_offset <= \ @@ -460,12 +460,12 @@ mhd_conn_process_data (struct MHD_Connection *restrict c) if (mhd_stream_prep_chunked_footer (c)) continue; break; - case MHD_CONNECTION_FOOTERS_SENDING: + case mhd_HTTP_STAGE_FOOTERS_SENDING: mhd_assert (c->rp.props.send_reply_body); mhd_assert (c->rp.props.chunked); /* no default action */ break; - case MHD_CONNECTION_FULL_REPLY_SENT: + case mhd_HTTP_STAGE_FULL_REPLY_SENT: // FIXME: support MHD_HTTP_STATUS_PROCESSING ? /* Reset connection after complete reply */ mhd_stream_finish_req_serving ( \ @@ -475,23 +475,23 @@ mhd_conn_process_data (struct MHD_Connection *restrict c) && ! c->sk.state.rmt_shut_wr); continue; #ifdef MHD_UPGRADE_SUPPORT - case MHD_CONNECTION_UPGRADING: + case mhd_HTTP_STAGE_UPGRADING: if (mhd_upgrade_finish_switch_to_upgraded (c)) return true; /* Do not close connection */ - mhd_assert (MHD_CONNECTION_PRE_CLOSING == c->state); + mhd_assert (mhd_HTTP_STAGE_PRE_CLOSING == c->stage); continue; - case MHD_CONNECTION_UPGRADED: + case mhd_HTTP_STAGE_UPGRADED: mhd_assert (0 && "Should be unreachable"); MHD_UNREACHABLE_; break; - case MHD_CONNECTION_UPGRADED_CLEANING: + case mhd_HTTP_STAGE_UPGRADED_CLEANING: mhd_assert (0 && "Should be unreachable"); MHD_UNREACHABLE_; break; #endif /* MHD_UPGRADE_SUPPORT */ - case MHD_CONNECTION_PRE_CLOSING: + case mhd_HTTP_STAGE_PRE_CLOSING: return false; - case MHD_CONNECTION_CLOSED: + case mhd_HTTP_STAGE_CLOSED: mhd_assert (0 && "Should be unreachable"); MHD_UNREACHABLE_; break; @@ -503,9 +503,9 @@ mhd_conn_process_data (struct MHD_Connection *restrict c) break; } - mhd_assert (MHD_CONNECTION_CLOSED != c->state); + mhd_assert (mhd_HTTP_STAGE_CLOSED != c->stage); - if (MHD_CONNECTION_PRE_CLOSING == c->state) + if (mhd_HTTP_STAGE_PRE_CLOSING == c->stage) { mhd_assert (0 && "Pre-closing should be already caught in the loop"); MHD_UNREACHABLE_; @@ -519,10 +519,10 @@ mhd_conn_process_data (struct MHD_Connection *restrict c) return true; } - if ((c->sk.state.rmt_shut_wr) && (MHD_CONNECTION_START_REPLY > c->state)) + if ((c->sk.state.rmt_shut_wr) && (mhd_HTTP_STAGE_START_REPLY > c->stage)) { mhd_conn_start_closing (c, - (MHD_CONNECTION_INIT == c->state) ? + (mhd_HTTP_STAGE_INIT == c->stage) ? mhd_CONN_CLOSE_HTTP_COMPLETED : mhd_CONN_CLOSE_CLIENT_SHUTDOWN_EARLY, NULL); diff --git a/src/mhd2/upgrade_prep.c b/src/mhd2/upgrade_prep.c index 438632fa..19738f60 100644 --- a/src/mhd2/upgrade_prep.c +++ b/src/mhd2/upgrade_prep.c @@ -152,7 +152,7 @@ build_reply_header (struct MHD_Connection *restrict c, mhd_assert (MHD_HTTP_VERSION_1_1 == c->rq.http_ver); mhd_assert ((0 == c->rq.cntn.cntn_size) || \ - (MHD_CONNECTION_FULL_REQ_RECEIVED == c->state)); + (mhd_HTTP_STAGE_FULL_REQ_RECEIVED == c->stage)); buf_used = 0; @@ -422,21 +422,21 @@ mhd_upgrade_prep_for_action (struct MHD_Request *restrict req, struct MHD_Connection *const c = mhd_cntnr_ptr (req, struct MHD_Connection, rq); - mhd_assert (MHD_CONNECTION_HEADERS_PROCESSED <= c->state); - mhd_assert (MHD_CONNECTION_FULL_REQ_RECEIVED >= c->state); + mhd_assert (mhd_HTTP_STAGE_HEADERS_PROCESSED <= c->stage); + mhd_assert (mhd_HTTP_STAGE_FULL_REQ_RECEIVED >= c->stage); if (req->have_chunked_upload && - (MHD_CONNECTION_FOOTERS_RECEIVED >= c->state)) + (mhd_HTTP_STAGE_FOOTERS_RECEIVED >= c->stage)) return false; /* The request has not been fully received */ if (! is_upload_act) { - if (MHD_CONNECTION_HEADERS_PROCESSED != c->state) + if (mhd_HTTP_STAGE_HEADERS_PROCESSED != c->stage) return false; } else { - if (MHD_CONNECTION_BODY_RECEIVING > c->state) + if (mhd_HTTP_STAGE_BODY_RECEIVING > c->stage) return false; } diff --git a/src/mhd2/upgrade_proc.c b/src/mhd2/upgrade_proc.c index ba922ad2..c8ba1860 100644 --- a/src/mhd2/upgrade_proc.c +++ b/src/mhd2/upgrade_proc.c @@ -49,7 +49,7 @@ MHD_INTERNAL MHD_FN_PAR_NONNULL_ (1) bool mhd_upgrade_try_start_upgrading (struct MHD_Connection *restrict c) { - mhd_assert (MHD_CONNECTION_UPGRADE_HEADERS_SENDING == c->state); + mhd_assert (mhd_HTTP_STAGE_UPGRADE_HEADERS_SENDING == c->stage); mhd_assert ((mhd_ACTION_UPGRADE == c->rq.app_act.head_act.act) || (mhd_UPLOAD_ACTION_UPGRADE == c->rq.app_act.upl_act.act)); mhd_assert (NULL != c->write_buffer); @@ -59,7 +59,7 @@ mhd_upgrade_try_start_upgrading (struct MHD_Connection *restrict c) if (c->write_buffer_append_offset != c->write_buffer_send_offset) return false; - c->state = MHD_CONNECTION_UPGRADING; + c->stage = mhd_HTTP_STAGE_UPGRADING; return true; } @@ -70,7 +70,7 @@ MHD_FN_PAR_NONNULL_ (1) bool mhd_upgrade_finish_switch_to_upgraded (struct MHD_Connection *restrict c) { struct mhd_UpgradeActionData *pupgr_data; - mhd_assert (MHD_CONNECTION_UPGRADING == c->state); + mhd_assert (mhd_HTTP_STAGE_UPGRADING == c->stage); mhd_assert (NULL != c->write_buffer); mhd_assert ((0 != c->read_buffer_offset) || (NULL == c->read_buffer)); mhd_assert (NULL == c->upgr.c); @@ -97,7 +97,7 @@ mhd_upgrade_finish_switch_to_upgraded (struct MHD_Connection *restrict c) mhd_conn_pre_clean_part1 (c); - c->state = MHD_CONNECTION_UPGRADED; + c->stage = mhd_HTTP_STAGE_UPGRADED; mhd_assert (! c->in_proc_ready); mhd_assert (NULL == mhd_DLINKEDL_GET_PREV (c, by_timeout)); @@ -121,10 +121,10 @@ MHD_upgraded_close (struct MHD_UpgradedHandle *urh) struct MHD_Connection *const restrict c = urh->c; struct MHD_Daemon *const restrict d = c->daemon; - if (MHD_CONNECTION_UPGRADED != c->state) /* Probably, assert would be better here */ + if (mhd_HTTP_STAGE_UPGRADED != c->stage) /* Probably, assert would be better here */ return MHD_SC_TOO_LATE; - c->state = MHD_CONNECTION_UPGRADED_CLEANING; + c->stage = mhd_HTTP_STAGE_UPGRADED_CLEANING; mhd_mutex_lock_chk (&(d->conns.upgr.ucu_lock)); mhd_DLINKEDL_INS_LAST (&(d->conns.upgr), c, upgr_cleanup); mhd_mutex_unlock_chk (&(d->conns.upgr.ucu_lock)); @@ -138,8 +138,8 @@ MHD_INTERNAL MHD_FN_PAR_NONNULL_ (1) void mhd_upgraded_deinit (struct MHD_Connection *restrict c) { - mhd_assert ((MHD_CONNECTION_UPGRADED_CLEANING == c->state) || \ - (MHD_CONNECTION_UPGRADED == c->state)); + mhd_assert ((mhd_HTTP_STAGE_UPGRADED_CLEANING == c->stage) || \ + (mhd_HTTP_STAGE_UPGRADED == c->stage)); mhd_assert (c == c->upgr.c); mhd_mutex_destroy_chk (&(c->upgr.lock)); diff --git a/src/mhd2/upgraded_net.c b/src/mhd2/upgraded_net.c index cd7b3c14..ab37e96f 100644 --- a/src/mhd2/upgraded_net.c +++ b/src/mhd2/upgraded_net.c @@ -120,7 +120,7 @@ MHD_upgraded_recv (struct MHD_UpgradedHandle *MHD_RESTRICT urh, if (&(c->upgr) != urh) return MHD_SC_UPGRADED_HANDLE_INVALID; - if (MHD_CONNECTION_UPGRADED != c->state) + if (mhd_HTTP_STAGE_UPGRADED != c->stage) return MHD_SC_UPGRADED_HANDLE_INVALID; if (0 == recv_buf_size) @@ -339,7 +339,7 @@ MHD_upgraded_send (struct MHD_UpgradedHandle *MHD_RESTRICT urh, if (&(c->upgr) != urh) return MHD_SC_UPGRADED_HANDLE_INVALID; - if (MHD_CONNECTION_UPGRADED != c->state) + if (mhd_HTTP_STAGE_UPGRADED != c->stage) return MHD_SC_UPGRADED_HANDLE_INVALID; finish_time_set = false;