[HTTPD] support for multiple simultaneous requests (IDFGH-9214) #10602
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
❌ Rejecting in favor of new PR: #10669 ❌
Related Issue: #10594
Add basic support for supporting multiple simultaneous requests in HTTPD server.
Implementation
httpd_req_copy(dest, source)
so that request memory ownership can be given to the userhttpd_req_claim_ownership(req)
to fully give ownership of the req to another thread, so the socket will not get purged bylru_purge_enable
, untilhttpd_req_relinquish_ownership(req)
is called.Open Question 1: It might be better to remove
httpd_req_copy(dest, source)
, and instead have the server allocate a new request object for each request. Possibly behind a,httpd_server.new_request_per_handler
, flag. Or, havehttpd_req_claim_ownership(req)
return a copy of the request.Open Question 2: Instead of calling
httpd_req_claim_ownership(req)
, the user's request handler could returnESP_ERR_NOT_FINISHED
, which would do the same thing. The user would then callhttpd_req_finish(req)
to mark the socket as purgeable again.In later ESP-IDF versions, we should probably make HTTPD have more "proper" simultaneous request support, at which point we could deprecate these functions perhaps. Lots of people have use cases for this, and this approach gives lots of control to users.
Example
Testing