[Top][All Lists]

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

Re: [libmicrohttpd] queuing error with MHD_queue_response in the middle

From: Christian Grothoff
Subject: Re: [libmicrohttpd] queuing error with MHD_queue_response in the middle of receiving data
Date: Fri, 7 Dec 2018 12:12:26 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0

Dear Zbigniew,

You are likely calling MHD_queue_repsonse() too late: once you are
receiving upload_data, HTTP forces you to process it all. At this time,
MHD has already sent "100 continue" and cannot take it back (hence you
get MHD_NO!).

In your request handler, the first time when you are called for a
connection (and when hence *upload_data_size == 0 and upload_data ==
NULL) you must check the content-length header and react (with
MHD_queue_response) based on this (to prevent MHD from automatically
generating 100 continue).

I hope this helps!


On 12/7/18 11:56 AM, Zbigniew Jędrzejewski-Szmek wrote:
> Hi,
> I have an application which tries to call [1]
> MHD_queue_response(..., MHD_HTTP_PAYLOAD_TOO_LARGE, ...) when received
> data is deemed to large. Unfortunately MHD_queue_response() always returns 
> connection->state is MHD_CONNECTION_CONTINUE_SENT at the time of this call,
> so the first check in MHD_queue_response() fails. The callback
> function gets the error back from MHD_queue_response() and propagates that,
> and the whole connection is aborted with
> "Application reported internal error, closing connection.".
> In this case waiting until the all of the input data has been read is
> not an attractive option (the data is potentially large and we don't want
> to waste sender or receiver time to pass bytes that will be discarded anyway).
> Is sending an error "in the middle" like this not supported at all?
> It would be really nice if the client would get the 413 code with the
> informative message.
> Thanks,
> Zbyszek
> [1] 

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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