aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-08-20 18:04:37 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-08-21 13:18:29 +0300
commit08d144ba1928085cc2e1ecb167ce380cab732b52 (patch)
treef7ab5173db37776cc84820e28089a1fe47a3f96d
parent5d35f4f7f93fcec65aee8d12944ad1105bf9b196 (diff)
downloadlibmicrohttpd-08d144ba1928085cc2e1ecb167ce380cab732b52.tar.gz
libmicrohttpd-08d144ba1928085cc2e1ecb167ce380cab732b52.zip
Do not use the same flag for chunked request and chunked reply
-rw-r--r--src/microhttpd/connection.c25
-rw-r--r--src/microhttpd/internal.h13
2 files changed, 18 insertions, 20 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 25cfe64b..df17fa61 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1655,8 +1655,6 @@ setup_reply_properties (struct MHD_Connection *connection)
1655 1655
1656 c->rp_props.chunked = use_chunked; 1656 c->rp_props.chunked = use_chunked;
1657 c->rp_props.set = true; 1657 c->rp_props.set = true;
1658 /* TODO: remove 'have_chunked_upload' assignment, use 'rp_props.chunked' */
1659 c->have_chunked_upload = c->rp_props.chunked;
1660} 1658}
1661 1659
1662 1660
@@ -1884,7 +1882,6 @@ build_header_response (struct MHD_Connection *connection)
1884 use_conn_k_alive = false; 1882 use_conn_k_alive = false;
1885 } 1883 }
1886 1884
1887
1888 /* ** Actually build the response header ** */ 1885 /* ** Actually build the response header ** */
1889 1886
1890 /* Get all space available */ 1887 /* Get all space available */
@@ -2051,8 +2048,7 @@ build_connection_chunked_response_footer (struct MHD_Connection *connection)
2051 struct MHD_Connection *const c = connection; /**< a short alias */ 2048 struct MHD_Connection *const c = connection; /**< a short alias */
2052 struct MHD_HTTP_Header *pos; 2049 struct MHD_HTTP_Header *pos;
2053 2050
2054 /* TODO: replace with 'use_chunked_send' */ 2051 mhd_assert (connection->rp_props.chunked);
2055 mhd_assert (connection->have_chunked_upload);
2056 /* TODO: allow combining of the final footer with the last chunk, 2052 /* TODO: allow combining of the final footer with the last chunk,
2057 * modify the next assert. */ 2053 * modify the next assert. */
2058 mhd_assert (MHD_CONNECTION_BODY_SENT == connection->state); 2054 mhd_assert (MHD_CONNECTION_BODY_SENT == connection->state);
@@ -3654,7 +3650,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
3654 if ( (NULL == resp->crc) && 3650 if ( (NULL == resp->crc) &&
3655 (NULL == resp->data_iov) && 3651 (NULL == resp->data_iov) &&
3656 (0 == connection->response_write_position) && 3652 (0 == connection->response_write_position) &&
3657 (! connection->have_chunked_upload) ) 3653 (! connection->rp_props.chunked) )
3658 { 3654 {
3659 mhd_assert (resp->total_size >= resp->data_size); 3655 mhd_assert (resp->total_size >= resp->data_size);
3660 /* Send response headers alongside the response body, if the body 3656 /* Send response headers alongside the response body, if the body
@@ -3708,7 +3704,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
3708 /* The complete header and some response data have been sent, 3704 /* The complete header and some response data have been sent,
3709 * update both offsets. */ 3705 * update both offsets. */
3710 mhd_assert (0 == connection->response_write_position); 3706 mhd_assert (0 == connection->response_write_position);
3711 mhd_assert (! connection->have_chunked_upload); 3707 mhd_assert (! connection->rp_props.chunked);
3712 connection->write_buffer_send_offset += wb_ready; 3708 connection->write_buffer_send_offset += wb_ready;
3713 connection->response_write_position = ret - wb_ready; 3709 connection->response_write_position = ret - wb_ready;
3714 } 3710 }
@@ -4029,13 +4025,13 @@ connection_reset (struct MHD_Connection *connection,
4029 new_read_buf_size); 4025 new_read_buf_size);
4030 c->read_buffer_size = new_read_buf_size; 4026 c->read_buffer_size = new_read_buf_size;
4031 c->continue_message_write_offset = 0; 4027 c->continue_message_write_offset = 0;
4032 c->responseCode = 0;
4033 c->headers_received = NULL; 4028 c->headers_received = NULL;
4034 c->headers_received_tail = NULL; 4029 c->headers_received_tail = NULL;
4035 c->response_write_position = 0;
4036 c->have_chunked_upload = false; 4030 c->have_chunked_upload = false;
4037 c->current_chunk_size = 0; 4031 c->current_chunk_size = 0;
4038 c->current_chunk_offset = 0; 4032 c->current_chunk_offset = 0;
4033 c->responseCode = 0;
4034 c->response_write_position = 0;
4039 c->method = NULL; 4035 c->method = NULL;
4040 c->http_mthd = MHD_HTTP_MTHD_NO_METHOD; 4036 c->http_mthd = MHD_HTTP_MTHD_NO_METHOD;
4041 c->url = NULL; 4037 c->url = NULL;
@@ -4356,7 +4352,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
4356 } 4352 }
4357#endif /* UPGRADE_SUPPORT */ 4353#endif /* UPGRADE_SUPPORT */
4358 4354
4359 if (connection->have_chunked_upload) 4355 if (connection->rp_props.chunked)
4360 connection->state = MHD_CONNECTION_CHUNKED_BODY_UNREADY; 4356 connection->state = MHD_CONNECTION_CHUNKED_BODY_UNREADY;
4361 else 4357 else
4362 connection->state = MHD_CONNECTION_NORMAL_BODY_UNREADY; 4358 connection->state = MHD_CONNECTION_NORMAL_BODY_UNREADY;
@@ -4375,8 +4371,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
4375 if (NULL != connection->response->crc) 4371 if (NULL != connection->response->crc)
4376 MHD_mutex_unlock_chk_ (&connection->response->mutex); 4372 MHD_mutex_unlock_chk_ (&connection->response->mutex);
4377#endif 4373#endif
4378 /* TODO: replace with 'use_chunked_send' */ 4374 if (connection->rp_props.chunked)
4379 if (connection->have_chunked_upload)
4380 connection->state = MHD_CONNECTION_BODY_SENT; 4375 connection->state = MHD_CONNECTION_BODY_SENT;
4381 else 4376 else
4382 connection->state = MHD_CONNECTION_FOOTERS_SENT; 4377 connection->state = MHD_CONNECTION_FOOTERS_SENT;
@@ -4432,8 +4427,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
4432 } 4427 }
4433 break; 4428 break;
4434 case MHD_CONNECTION_BODY_SENT: 4429 case MHD_CONNECTION_BODY_SENT:
4435 /* TODO: replace with 'use_chunked_send' */ 4430 mhd_assert (connection->rp_props.chunked);
4436 mhd_assert (connection->have_chunked_upload);
4437 4431
4438 if (MHD_NO == build_connection_chunked_response_footer (connection)) 4432 if (MHD_NO == build_connection_chunked_response_footer (connection))
4439 { 4433 {
@@ -4443,7 +4437,8 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
4443 "Closing connection (failed to create response footer).")); 4437 "Closing connection (failed to create response footer)."));
4444 continue; 4438 continue;
4445 } 4439 }
4446 if ( (! connection->have_chunked_upload) || 4440 /* TODO: remove next 'if' */
4441 if ( (! connection->rp_props.chunked) ||
4447 (connection->write_buffer_send_offset == 4442 (connection->write_buffer_send_offset ==
4448 connection->write_buffer_append_offset) ) 4443 connection->write_buffer_append_offset) )
4449 connection->state = MHD_CONNECTION_FOOTERS_SENT; 4444 connection->state = MHD_CONNECTION_FOOTERS_SENT;
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index fc521832..1524ced3 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -1233,11 +1233,14 @@ struct MHD_Connection
1233 struct MHD_Reply_Properties rp_props; 1233 struct MHD_Reply_Properties rp_props;
1234 1234
1235 /** 1235 /**
1236 * Are we receiving with chunked encoding? This will be set to 1236 * Are we receiving with chunked encoding?
1237 * #MHD_YES after we parse the headers and are processing the body 1237 * This will be set to #MHD_YES after we parse the headers and
1238 * with chunks. After we are done with the body and we are 1238 * are processing the body with chunks.
1239 * processing the footers; once the footers are also done, this will 1239 * After we are done with the body and we are processing the footers;
1240 * be set to #MHD_NO again (before the final call to the handler). 1240 * once the footers are also done, this will be set to #MHD_NO again
1241 * (before the final call to the handler).
1242 * It is used only for requests, chunked encoding for response is
1243 * indicated by @a rp_props.
1241 */ 1244 */
1242 bool have_chunked_upload; 1245 bool have_chunked_upload;
1243 1246