View Issue Details

IDProjectCategoryView StatusLast Update
0006068libmicrohttpdotherpublic2021-09-02 17:54
Reporterclennon Assigned ToChristian Grothoff  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformLinuxOSCentOSOS Version7
Product Version0.9.69 
Target Version0.9.70Fixed in Version0.9.70 
Summary0006068: No response using PATCH method with data
DescriptionI'm using the following to send a response to a HTTP request:

#define FORBIDDEN "{\"error_text\": \"Permission Denied\"}"
struct MHD_Response *response=NULL;
response = MHD_create_response_from_buffer(strlen (FORBIDDEN),
                                           (void *) FORBIDDEN,
                                           MHD_RESPMEM_PERSISTENT);
MHD_add_response_header(response, "Content-Type", "application/json");
ret = MHD_queue_response (connection, MHD_HTTP_FORBIDDEN, response);
MHD_destroy_response (response);

For a PUT request with data, the client is getting the response.

However, with a PATCH request with data, the client is not getting a response.

Looking at the MHD_connection_handle_idle function src/microhttpd/connection.c I can see that the POST and PUT methods are
handled differently to everything else (e.g. when the state is MHD_CONNECTION_HEADERS_PROCESSED)
TagsNo tags attached.
Attached Files

Activities

clennon

2020-01-29 15:47

reporter   ~0015302

git diff that fixes this
libmicrohttpd_PATCH.patch (1,195 bytes)   
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 52f57ae..e5eb7ab 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -3412,6 +3412,8 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
            ( (MHD_str_equal_caseless_ (connection->method,
                                        MHD_HTTP_METHOD_POST)) ||
              (MHD_str_equal_caseless_ (connection->method,
+                                       MHD_HTTP_METHOD_PATCH)) ||
+             (MHD_str_equal_caseless_ (connection->method,
                                        MHD_HTTP_METHOD_PUT))) )
       {
         /* we refused (no upload allowed!) */
@@ -4041,6 +4043,8 @@ MHD_queue_response (struct MHD_Connection *connection,
        ( (MHD_str_equal_caseless_ (connection->method,
                                    MHD_HTTP_METHOD_POST)) ||
          (MHD_str_equal_caseless_ (connection->method,
+                                   MHD_HTTP_METHOD_PATCH)) ||
+         (MHD_str_equal_caseless_ (connection->method,
                                    MHD_HTTP_METHOD_PUT))) )
   {
     /* response was queued "early", refuse to read body / footers or

libmicrohttpd_PATCH.patch (1,195 bytes)   

Christian Grothoff

2020-02-07 23:50

manager   ~0015316

Well, while I'd like to support this for PATCH, the proposed diff is not nice. Basically, the problem is that this style will require us to add each method to the list, and there are potentially many more. Instead, we should probably simply test for the client having sent '100 continue' *and* headers indicative that a body may follow. Then the 100 continue logic should run. And if there is no upload, then the application should queue the final reply immediately anyway.

Christian Grothoff

2020-02-08 16:52

manager   ~0015317

44c32e4c..78d0fb7b should fix this properly. I would appreciate it if you could quickly test it and report back.

Christian Grothoff

2020-02-08 21:59

manager   ~0015322

Reporter confirmed this fixes the issue.

Christian Grothoff

2021-09-02 17:54

manager   ~0018169

Fix committed to master branch.

Related Changesets

libmicrohttpd: master 78d0fb7b

2020-02-08 17:48

Christian Grothoff


Details Diff
fix 0006068 (enable 100 continue handling for PATCH requests) Affected Issues
0006068
mod - src/microhttpd/connection.c Diff File

Issue History

Date Modified Username Field Change
2020-01-29 12:38 clennon New Issue
2020-01-29 15:47 clennon File Added: libmicrohttpd_PATCH.patch
2020-01-29 15:47 clennon Note Added: 0015302
2020-02-07 14:16 Christian Grothoff Assigned To => Christian Grothoff
2020-02-07 14:16 Christian Grothoff Status new => assigned
2020-02-07 23:50 Christian Grothoff Note Added: 0015316
2020-02-07 23:50 Christian Grothoff Target Version => 0.9.70
2020-02-08 16:52 Christian Grothoff Note Added: 0015317
2020-02-08 16:52 Christian Grothoff Assigned To Christian Grothoff =>
2020-02-08 16:52 Christian Grothoff Status assigned => feedback
2020-02-08 21:59 Christian Grothoff Assigned To => Christian Grothoff
2020-02-08 21:59 Christian Grothoff Status feedback => resolved
2020-02-08 21:59 Christian Grothoff Resolution open => fixed
2020-02-08 21:59 Christian Grothoff Fixed in Version => 0.9.70
2020-02-08 21:59 Christian Grothoff Note Added: 0015322
2020-02-08 22:03 Christian Grothoff Status resolved => closed
2021-09-02 17:54 Christian Grothoff Changeset attached => libmicrohttpd master 78d0fb7b
2021-09-02 17:54 Christian Grothoff Note Added: 0018169