Thanks for that useful advice.
Yes - I think my issue is that I'm getting several requests.
Is there any way to configure libmicrohttpd to not accept a new HTTP request,
or at least not call MHD_AccessHandlerCallback, until the previous
(chunked) response has completed?
Looking at the MHD_FLAGS enumeration, nothing is jumping out at me.
On 18/06/2021 15:18, Evgeny Grin wrote:
Hi Conor,
If I've got you right, the question is not about large responses, but about
simultaneous handling of several responses at the same time.
It is implemented very easily. When your application processes request, it
should decide how you construct your response: for example, make
request A for database B or read picture X and convert it to to the format Z.
Then you need to put all parameters (the name of database and the request or
picture location and final format) to the callback parameter
variable. See chunked_example.c, where 'callback_param' is always initialized
with the same date. In practice it should be initialized with
data varied depending on the request.
If you are reusing the same response (struct MHD_Response object) for several
requests, you must ensure that your callback generates response
data for response position provided as callback parameter. In this case it
doesn't matter which request is served, the data is determined by
response object and position.
Alternatively, if you are using unique responses for each request (as it was
done in the example), you can put (update) number of last line
sent to the client into your callback parameter and start your next chunk from
the next line.