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!

Christian

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 
> MHD_NO.
> 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] 
> https://github.com/systemd/systemd/blob/master/src/journal-remote/journal-remote-main.c#L220
> 

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to