aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-02-08 16:48:21 +0100
committerChristian Grothoff <christian@grothoff.org>2020-02-08 16:48:42 +0100
commit78d0fb7b293a8284f4b4d29deae5beb44bdcaf8e (patch)
tree78ddbbf30b9b89b107acafa8f53d659b9a6289ad
parent44c32e4ca7aa54009b4af55678407a71e6965327 (diff)
downloadlibmicrohttpd-78d0fb7b293a8284f4b4d29deae5beb44bdcaf8e.tar.gz
libmicrohttpd-78d0fb7b293a8284f4b4d29deae5beb44bdcaf8e.zip
fix #6068 (enable 100 continue handling for PATCH requests)
-rw-r--r--src/microhttpd/connection.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 52f57aec..3f47c924 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of libmicrohttpd 2 This file is part of libmicrohttpd
3 Copyright (C) 2007-2019 Daniel Pittman and Christian Grothoff 3 Copyright (C) 2007-2020 Daniel Pittman and Christian Grothoff
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public 6 modify it under the terms of the GNU Lesser General Public
@@ -24,7 +24,6 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 * @author Karlson2k (Evgeny Grin) 25 * @author Karlson2k (Evgeny Grin)
26 */ 26 */
27
28#include "internal.h" 27#include "internal.h"
29#include "mhd_limits.h" 28#include "mhd_limits.h"
30#include "connection.h" 29#include "connection.h"
@@ -687,8 +686,7 @@ need_100_continue (struct MHD_Connection *connection)
687{ 686{
688 const char *expect; 687 const char *expect;
689 688
690 return ( (NULL == connection->response) && 689 return ( (NULL != connection->version) &&
691 (NULL != connection->version) &&
692 (MHD_str_equal_caseless_ (connection->version, 690 (MHD_str_equal_caseless_ (connection->version,
693 MHD_HTTP_VERSION_1_1)) && 691 MHD_HTTP_VERSION_1_1)) &&
694 (MHD_NO != MHD_lookup_connection_value_n (connection, 692 (MHD_NO != MHD_lookup_connection_value_n (connection,
@@ -699,9 +697,7 @@ need_100_continue (struct MHD_Connection *connection)
699 &expect, 697 &expect,
700 NULL)) && 698 NULL)) &&
701 (MHD_str_equal_caseless_ (expect, 699 (MHD_str_equal_caseless_ (expect,
702 "100-continue")) && 700 "100-continue")) );
703 (connection->continue_message_write_offset <
704 MHD_STATICSTR_LEN_ (HTTP_100_CONTINUE)) );
705} 701}
706 702
707 703
@@ -3403,16 +3399,14 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
3403 continue; 3399 continue;
3404 if (connection->suspended) 3400 if (connection->suspended)
3405 continue; 3401 continue;
3406 if (need_100_continue (connection)) 3402 if ( (NULL == connection->response) &&
3403 (need_100_continue (connection)) )
3407 { 3404 {
3408 connection->state = MHD_CONNECTION_CONTINUE_SENDING; 3405 connection->state = MHD_CONNECTION_CONTINUE_SENDING;
3409 break; 3406 break;
3410 } 3407 }
3411 if ( (NULL != connection->response) && 3408 if ( (NULL != connection->response) &&
3412 ( (MHD_str_equal_caseless_ (connection->method, 3409 (0 != connection->remaining_upload_size) )
3413 MHD_HTTP_METHOD_POST)) ||
3414 (MHD_str_equal_caseless_ (connection->method,
3415 MHD_HTTP_METHOD_PUT))) )
3416 { 3410 {
3417 /* we refused (no upload allowed!) */ 3411 /* we refused (no upload allowed!) */
3418 connection->remaining_upload_size = 0; 3412 connection->remaining_upload_size = 0;
@@ -3420,8 +3414,8 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
3420 connection->read_closed = true; 3414 connection->read_closed = true;
3421 } 3415 }
3422 connection->state = (0 == connection->remaining_upload_size) 3416 connection->state = (0 == connection->remaining_upload_size)
3423 ? MHD_CONNECTION_FOOTERS_RECEIVED : 3417 ? MHD_CONNECTION_FOOTERS_RECEIVED
3424 MHD_CONNECTION_CONTINUE_SENT; 3418 : MHD_CONNECTION_CONTINUE_SENT;
3425 if (connection->suspended) 3419 if (connection->suspended)
3426 break; 3420 break;
3427 continue; 3421 continue;
@@ -4036,17 +4030,13 @@ MHD_queue_response (struct MHD_Connection *connection,
4036 have already sent the full message body. */ 4030 have already sent the full message body. */
4037 connection->response_write_position = response->total_size; 4031 connection->response_write_position = response->total_size;
4038 } 4032 }
4039 if ( (MHD_CONNECTION_HEADERS_PROCESSED == connection->state) && 4033 if (MHD_CONNECTION_HEADERS_PROCESSED == connection->state)
4040 (NULL != connection->method) &&
4041 ( (MHD_str_equal_caseless_ (connection->method,
4042 MHD_HTTP_METHOD_POST)) ||
4043 (MHD_str_equal_caseless_ (connection->method,
4044 MHD_HTTP_METHOD_PUT))) )
4045 { 4034 {
4046 /* response was queued "early", refuse to read body / footers or 4035 /* response was queued "early", refuse to read body / footers or
4047 further requests! */ 4036 further requests! */
4048 connection->read_closed = true; 4037 connection->read_closed = true;
4049 connection->state = MHD_CONNECTION_FOOTERS_RECEIVED; 4038 connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
4039 connection->remaining_upload_size = 0;
4050 } 4040 }
4051 if (! connection->in_idle) 4041 if (! connection->in_idle)
4052 (void) MHD_connection_handle_idle (connection); 4042 (void) MHD_connection_handle_idle (connection);