aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/connection.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/connection.c')
-rw-r--r--src/microhttpd/connection.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 643ef52a..dab28878 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -800,7 +800,7 @@ MHD_lookup_connection_value_n (struct MHD_Connection *connection,
800 { 800 {
801 for (pos = connection->headers_received; NULL != pos; pos = pos->next) 801 for (pos = connection->headers_received; NULL != pos; pos = pos->next)
802 { 802 {
803 if ( (kind == pos->kind) && 803 if ( (0 != (kind & pos->kind)) &&
804 (NULL == pos->header) ) 804 (NULL == pos->header) )
805 break; 805 break;
806 } 806 }
@@ -809,7 +809,7 @@ MHD_lookup_connection_value_n (struct MHD_Connection *connection,
809 { 809 {
810 for (pos = connection->headers_received; NULL != pos; pos = pos->next) 810 for (pos = connection->headers_received; NULL != pos; pos = pos->next)
811 { 811 {
812 if ( (kind == pos->kind) && 812 if ( (0 != (kind & pos->kind)) &&
813 (key_size == pos->header_size) && 813 (key_size == pos->header_size) &&
814 ( (key == pos->header) || 814 ( (key == pos->header) ||
815 (MHD_str_equal_caseless_bin_n_ (key, 815 (MHD_str_equal_caseless_bin_n_ (key,
@@ -2454,7 +2454,19 @@ process_request_body (struct MHD_Connection *connection)
2454 char *buffer_head; 2454 char *buffer_head;
2455 2455
2456 if (NULL != connection->response) 2456 if (NULL != connection->response)
2457 return; /* already queued a response */ 2457 {
2458 /* already queued a response, discard remaining upload
2459 (but not more, there might be another request after it) */
2460 uint64_t purge = MHD_MIN (connection->remaining_upload_size,
2461 connection->read_buffer_offset);
2462 connection->remaining_upload_size -= purge;
2463 if (connection->read_buffer_offset > purge)
2464 memmove (connection->read_buffer,
2465 &connection->read_buffer[purge],
2466 connection->read_buffer_offset - purge);
2467 connection->read_buffer_offset -= purge;
2468 return;
2469 }
2458 2470
2459 buffer_head = connection->read_buffer; 2471 buffer_head = connection->read_buffer;
2460 available = connection->read_buffer_offset; 2472 available = connection->read_buffer_offset;
@@ -2589,19 +2601,19 @@ process_request_body (struct MHD_Connection *connection)
2589 { 2601 {
2590 /* no chunked encoding, give all to the client */ 2602 /* no chunked encoding, give all to the client */
2591 if ( (0 != connection->remaining_upload_size) && 2603 if ( (0 != connection->remaining_upload_size) &&
2592 (MHD_SIZE_UNKNOWN != connection->remaining_upload_size) && 2604 (MHD_SIZE_UNKNOWN != connection->remaining_upload_size) &&
2593 (connection->remaining_upload_size < available) ) 2605 (connection->remaining_upload_size < available) )
2594 { 2606 {
2595 to_be_processed = (size_t)connection->remaining_upload_size; 2607 to_be_processed = (size_t)connection->remaining_upload_size;
2596 } 2608 }
2597 else 2609 else
2598 { 2610 {
2599 /** 2611 /**
2600 * 1. no chunked encoding, give all to the client 2612 * 1. no chunked encoding, give all to the client
2601 * 2. client may send large chunked data, but only a smaller part is available at one time. 2613 * 2. client may send large chunked data, but only a smaller part is available at one time.
2602 */ 2614 */
2603 to_be_processed = available; 2615 to_be_processed = available;
2604 } 2616 }
2605 } 2617 }
2606 left_unprocessed = to_be_processed; 2618 left_unprocessed = to_be_processed;
2607 connection->client_aware = true; 2619 connection->client_aware = true;