libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] How much upload_data is uploaded to MHD_AccessHandle


From: Christian Grothoff
Subject: Re: [libmicrohttpd] How much upload_data is uploaded to MHD_AccessHandlerCallback()?
Date: Fri, 11 Sep 2015 07:58:15 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0

On 09/11/2015 01:56 AM, Bob Furber wrote:
> Can someone tell me how much upload_data is uploaded to
> MHD_AccessHandlerCallback()?

As much as is available at the time, except for chunked encoding. If the
client sends data with chunked encoding, then you may get each chunk
separately as we want to avoid having to memcpy().

> Can the upload_data uploaded to MHD_AccessHandlerCallback() ever be less
> than the lesser of all the data sent by the client or the size of the
> upload_data buffer?

It should generally be the MIN of those two, modulo the OS not making
all data available to MHD in a 'read/recv()' call and the possibility of
chunked encoding. (I think theoretically the OS could provide less data
than the full amount received for a TCP socket.)

So while in practice you are right about it, we don't make a formal
guarantee that this is true.

> In other words, if a POST request were to contain, say, 64 bytes and the
> upload_data buffer were larger, say, 256 bytes, could the upload_data
> buffer contain anything less than 64 bytes? Could one expect a short
> POST request to arrive in more than one packet?

The most crazy OS I'm aware of uses a TCP window of 1 byte and passes
TCP packets 1 byte at a time to the application, but there the OS has
technically not received (TCP-acknowledged) more than 1 byte at a time
either.

So this depends quite a bit on how portable you want to make your code.
Also, you may theoretically have a client that uses chunked encoding and
sends <64 bytes in the 1st chunk.

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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