|
From: | Evgeny Grin |
Subject: | Re: [libmicrohttpd] chunked data mixed across multiple GETs |
Date: | Fri, 18 Jun 2021 17:18:43 +0300 |
User-agent: | Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 |
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.
-- Wishes, Evgeny On 17.06.2021 18:48, Conor Lennon via libmicrohttpd wrote:
I have a application that uses libmicrohttpd Data is stored in an sqlite database and we support GET, POST, PATCH and DELETE HTTP methods to manage the data. As part of the GET, we call MHD_create_response_from_callback with a callback function that reads the next value from the database and sends it back as chunked data. The problem that we are seeing is that two consecutive GETs can interfere with each other when the first GET has a lot of data to return. What appears to be happening is that data matching the filter of the second GET is being included in the response for the first GET. Are there any suggestions on how we can proceed with investigating this? I see that src/examples/chunked_example.c uses MHD_create_response_from_callback, but I'm not sure how to use that example to test out large data. Regards, Conor
OpenPGP_signature
Description: OpenPGP digital signature
[Prev in Thread] | Current Thread | [Next in Thread] |