fix #292 change get_args to return mutliple values per key#293
Closed
stuart-byma wants to merge 1 commit intoetr:masterfrom
Closed
fix #292 change get_args to return mutliple values per key#293stuart-byma wants to merge 1 commit intoetr:masterfrom
stuart-byma wants to merge 1 commit intoetr:masterfrom
Conversation
Update the full arguments processing test to make sure the new behavior is as desired.
mdf-observe
reviewed
Dec 22, 2022
| (*aa->arguments)[key] = value; | ||
| auto existing_iter = aa->arguments->find(key); | ||
| if (existing_iter != aa->arguments->end()) { | ||
| // Key exists, add value to collection instead of overwriting previous value. |
There was a problem hiding this comment.
Whether the key exists or not, I think this if/else equivalent to just:
(*aa->arguments)[key].push_back(value);
| void set_arg(const std::string& key, const std::string& value) { | ||
| cache->unescaped_args[key] = value.substr(0, content_size_limit); | ||
| auto existing_iter = cache->unescaped_args.find(key); | ||
| if (existing_iter != cache->unescaped_args.end()) { |
There was a problem hiding this comment.
Similarly I think this is also just cache->unescaped_args[key].push_back(value.substr(0, content_size_limit));, and below.
| @@ -105,20 +105,31 @@ const http::header_view_map http_request::get_cookies() const { | |||
| } | |||
|
|
|||
| std::string_view http_request::get_arg(std::string_view key) const { | |||
There was a problem hiding this comment.
Since get_arg() now returns only the first matching item (which does keep the API the same), should there also be a get_args() method that returns a std::span<const std::string> or whatever type makes the least memory allocations? IIRC a span<const T> can be made from a vector<T> implicitly.
Contributor
Author
There was a problem hiding this comment.
afaik span is C++20, so this would require bumping the min version from 17.
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.
Requirements for Contributing a Bug Fix
Identify the Bug
#292
Description of the Change
Change arg_map and arg_view_map to
std::map<std::string, std::vector<std::string>>etc, so that multiple values per key can be returned.Update an appropriate test case to check that the behavior is correct.
Alternate Designs
No alternate designs
Possible Drawbacks
Small change to user facing API.
Verification Process
Tests were updated to check that new code is correct.
Release Notes