Closes #268: Fix POST processing of final keys without values#269
Closed
JavierJF wants to merge 1 commit intoetr:masterfrom
Closed
Closes #268: Fix POST processing of final keys without values#269JavierJF wants to merge 1 commit intoetr:masterfrom
JavierJF wants to merge 1 commit intoetr:masterfrom
Conversation
'MHD_destroy_post_processor' should be called before the request callback for ensuring the processing of final keys without terminated values.
a2dece8 to
c2f6d28
Compare
etr
reviewed
May 14, 2022
| if (found) { | ||
| try { | ||
| if (hrm->is_allowed(method)) { | ||
| if (mr->pp != NULL) { |
Owner
There was a problem hiding this comment.
nit: can we use nullptr instead of NULL
etr
reviewed
May 14, 2022
Owner
etr
left a comment
There was a problem hiding this comment.
Thanks for the fix. Looks good overall - I left you a nitpicky comment about NULL vs nullptr.
I think the only missing thing is a test proving the use-case you spotted and the fact that it now works.
etr
added a commit
that referenced
this pull request
Jan 27, 2026
Destroy post processor before invoking the callback to ensure pending POST body keys with empty values are properly finalized. Without this, POST data like "arg1=val1&arg2=" would fail to include arg2. The fix moves MHD_destroy_post_processor call to finalize_answer() before the resource callback is invoked, rather than waiting for the modded_request destructor. Added test cases verifying: - arg1=val1&arg2= correctly parses both args - arg1= correctly parses as empty string - arg1=&arg2= correctly parses both as empty strings This supersedes PR #269 with the requested code style changes.
3 tasks
Owner
|
This PR has been superseded by #351, which includes the requested changes (using |
etr
added a commit
that referenced
this pull request
Jan 27, 2026
Destroy post processor before invoking the callback to ensure pending POST body keys with empty values are properly finalized. Without this, POST data like "arg1=val1&arg2=" would fail to include arg2. The fix moves MHD_destroy_post_processor call to finalize_answer() before the resource callback is invoked, rather than waiting for the modded_request destructor. Added test cases verifying: - arg1=val1&arg2= correctly parses both args - arg1= correctly parses as empty string - arg1=&arg2= correctly parses both as empty strings This supersedes PR #269 with the requested code style changes.
etr
added a commit
that referenced
this pull request
Jan 27, 2026
* Fix POST args with empty values not being parsed (issue #268) Destroy post processor before invoking the callback to ensure pending POST body keys with empty values are properly finalized. Without this, POST data like "arg1=val1&arg2=" would fail to include arg2. The fix moves MHD_destroy_post_processor call to finalize_answer() before the resource callback is invoked, rather than waiting for the modded_request destructor. Added test cases verifying: - arg1=val1&arg2= correctly parses both args - arg1= correctly parses as empty string - arg1=&arg2= correctly parses both as empty strings This supersedes PR #269 with the requested code style changes. * Fix Windows build: replace rand_r with portable rand() rand_r is POSIX-specific and not available on Windows. Since this is just a stress test where thread-safe randomness isn't critical, use the portable rand() function instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Identify the Bug
#268
Description of the Change
The change is simple, instead of calling 'MHD_destroy_post_processor' in the destructor after the request has been processed, it's called before calling the registered processing callback.
Alternate Designs
I haven't think in alternate designs. I chose to call 'MHD_destroy_post_processor' right before
mr->callbackbecause I think it's the only place requiring of the final post processing of the request. Thus, keeping the two operation close makes sense.Possible Drawbacks
If all the information is going to be used just by
mr->callback, can't think of any drawback.Verification Process
Sorry, internal testing, just testing over the endpoints in a third party application.
Release Notes