libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] Problems using PATCH method


From: Conor Lennon
Subject: Re: [libmicrohttpd] Problems using PATCH method
Date: Wed, 5 Feb 2020 09:12:32 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

Hi Christian,

Thanks for your response.

I think you've identified the issue.

In the scenario that I have, I'm checking whether the user has permission to 
send a PATCH to the url.

If they don't, then I'm queueing the error response immediately.

This is before I'm checking the upload data.

If this is not something that libmicrohttpd is not going to support for PATCH 
(in the same way that it does for PUT and POST), then fair enough.

Regards,

Conor

On 04/02/2020 19:29, Christian Grothoff wrote:
> Hi Conor,
>
> I've tried to test this, and could not find an issue.  You can find a
> new test case for MHD's PATCH handling in Git, as per change
> b8a0f698..2d4289dc.  However, as the test worked instantly, I could not
> find any bug with it.
>
> The special handling of PUT/POST you mention likely refers to MHD's
> handling for "100 CONTINUE". So sure, if you rely on "100 CONTINUE"
> that likely only works with PUT/POST. 
>
> My main idea as to what you might be doing wrong is queuing a response
> before the upload is complete. With PUT/POST and "Expect: 100-
> continue", this is supported by MHD. For other methods, you must wait
> until you have received the full upload (if there is one) and only then
> queue the response.
>
> I suggest you look at the new 'test_patch.c', and if that doesn't help,
> please send us some running minimal example to reproduce your issue.
>
> Happy hacking!
>
> Christian
>
> On Wed, 2020-01-22 at 16:44 +0000, Conor Lennon via libmicrohttpd
> wrote:
>> Hi,
>>
>> I'm using libmicrohttpd 0.9.63.
>>
>> Looking at the libmicrohttpd code, I don't think the behaviour has
>> changed since then.
>>
>> I'm investigating a problem that I'm having with a PATCH request.
>>
>> It's being handled differently from a PUT request.
>>
>> I'm using the following to send a response to the 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, the client is getting the response.
>>
>> However, with a PATCH request, the client is not getting a response.
>>
>> I'm using curl as the HTTP client.
>>
>> 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)
>>
>> Is there a reason for that?
>>
>> Should I be calling some other function to better handle the PATCH
>> method?
>>
>> I get similar behaviour with a random method when I send data.
>>
>> Looking at the examples that libmicrohttpd comes with, I don't see
>> any methods being used other than GET, HEAD and POST.
>>
>> Thanks in advance,
>>
>> Conor
>>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]