View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0006068 | libmicrohttpd | other | public | 2020-01-29 12:38 | 2021-09-02 17:54 |
Reporter | clennon | Assigned To | Christian Grothoff | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | Linux | OS | CentOS | OS Version | 7 |
Product Version | 0.9.69 | ||||
Target Version | 0.9.70 | Fixed in Version | 0.9.70 | ||
Summary | 0006068: No response using PATCH method with data | ||||
Description | I'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) | ||||
Tags | No tags attached. | ||||
Attached Files | |||||
|
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 |
|
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. |
|
44c32e4c..78d0fb7b should fix this properly. I would appreciate it if you could quickly test it and report back. |
|
Reporter confirmed this fixes the issue. |
|
Fix committed to master branch. |
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 |