Skip to content

Conversation

@stuart-byma
Copy link
Contributor

Identify the Bug

#292

Description of the Change

This change allows the server to handle argument keys with multiple values e.g. url?arg=param&arg=what

Previous, the arg key would just be overwritten with the next value. This change adds a http_arg_value type to house all the values for a given key.

Adjust existing get_arg(s) methods, and add some get_arg_flat type methods that still just return the first value for a given key.

Add a test case for multiple valued keys.

Add a test case for a large file upload that triggers chunking behavior of MHD. This causes the server to concatenate file chunks within the first value of the given arg key, so the test ensures that this behavior is not affected by the changes.

Alternate Designs

Design is according to discussion in #292

Possible Drawbacks

Small changes to public API.

Verification Process

Additional testing added as in change description. In particular, verify that large file handling behavior has not regressed.

Release Notes

  • Multiple valued arguments are now supported, e.g. URLs containing ?arg=param1&arg=param2. get_arg() now returns an http_arg_value type containing a collection of all values associated with the requested key. get_arg_flat() retains the old behavior where just one value is selected and returned.

This change allows the server to handle argument keys with multiple values
e.g. url?arg=param&arg=what

Previous, the arg key would just be overwritten with the next value. This
change adds a http_arg_value type to house all the values for a given key.

Adjust existing get_arg(s) methods, and add some get_arg_flat type
methods that still just return the first value for a given key.

Add a test case for multiple valued keys.

Add a test case for a large file upload that triggers chunking behavior
of MHD. This causes the server to concatenate file chunks within the
first value of the given arg key, so the test ensures that this
behavior is not affected by the changes.
This change allows the server to handle argument keys with multiple values
e.g. url?arg=param&arg=what

Previous, the arg key would just be overwritten with the next value. This
change adds a http_arg_value type to house all the values for a given key.

Adjust existing get_arg(s) methods, and add some get_arg_flat type
methods that still just return the first value for a given key.

Add a test case for multiple valued keys.

Add a test case for a large file upload that triggers chunking behavior
of MHD. This causes the server to concatenate file chunks within the
first value of the given arg key, so the test ensures that this
behavior is not affected by the changes.
This change allows the server to handle argument keys with multiple values
e.g. url?arg=param&arg=what

Previous, the arg key would just be overwritten with the next value. This
change adds a http_arg_value type to house all the values for a given key.

Adjust existing get_arg(s) methods, and add some get_arg_flat type
methods that still just return the first value for a given key.

Add a test case for multiple valued keys.

Add a test case for a large file upload that triggers chunking behavior
of MHD. This causes the server to concatenate file chunks within the
first value of the given arg key, so the test ensures that this
behavior is not affected by the changes.
This change allows the server to handle argument keys with multiple values
e.g. url?arg=param&arg=what

Previous, the arg key would just be overwritten with the next value. This
change adds a http_arg_value type to house all the values for a given key.

Adjust existing get_arg(s) methods, and add some get_arg_flat type
methods that still just return the first value for a given key.

Add a test case for multiple valued keys.

Add a test case for a large file upload that triggers chunking behavior
of MHD. This causes the server to concatenate file chunks within the
first value of the given arg key, so the test ensures that this
behavior is not affected by the changes.
This change allows the server to handle argument keys with multiple values
e.g. url?arg=param&arg=what

Previous, the arg key would just be overwritten with the next value. This
change adds a http_arg_value type to house all the values for a given key.

Adjust existing get_arg(s) methods, and add some get_arg_flat type
methods that still just return the first value for a given key.

Add a test case for multiple valued keys.

Add a test case for a large file upload that triggers chunking behavior
of MHD. This causes the server to concatenate file chunks within the
first value of the given arg key, so the test ensures that this
behavior is not affected by the changes.
This change allows the server to handle argument keys with multiple values
e.g. url?arg=param&arg=what

Previous, the arg key would just be overwritten with the next value. This
change adds a http_arg_value type to house all the values for a given key.

Adjust existing get_arg(s) methods, and add some get_arg_flat type
methods that still just return the first value for a given key.

Add a test case for multiple valued keys.

Add a test case for a large file upload that triggers chunking behavior
of MHD. This causes the server to concatenate file chunks within the
first value of the given arg key, so the test ensures that this
behavior is not affected by the changes.
This change allows the server to handle argument keys with multiple values
e.g. url?arg=param&arg=what

Previous, the arg key would just be overwritten with the next value. This
change adds a http_arg_value type to house all the values for a given key.

Adjust existing get_arg(s) methods, and add some get_arg_flat type
methods that still just return the first value for a given key.

Add a test case for multiple valued keys.

Add a test case for a large file upload that triggers chunking behavior
of MHD. This causes the server to concatenate file chunks within the
first value of the given arg key, so the test ensures that this
behavior is not affected by the changes.
Comment on lines 660 to 662
// Change the content type to trigger "normal" POST processing,
// otherwise the file processing logic is triggered which does
// not set the multiple arg values as expected.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you might have lost me here. Why does this need to be done?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without a different content type the defaults that cURL sets trigger the file processing code, but in this test I am just trying to check the "normal" arg handling with multiple values.

This change allows the server to handle argument keys with multiple values
e.g. url?arg=param&arg=what

Previous, the arg key would just be overwritten with the next value. This
change adds a http_arg_value type to house all the values for a given key.

Adjust existing get_arg(s) methods, and add some get_arg_flat type
methods that still just return the first value for a given key.

Add a test case for multiple valued keys.

Add a test case for a large file upload that triggers chunking behavior
of MHD. This causes the server to concatenate file chunks within the
first value of the given arg key, so the test ensures that this
behavior is not affected by the changes.
This change allows the server to handle argument keys with multiple values
e.g. url?arg=param&arg=what

Previous, the arg key would just be overwritten with the next value. This
change adds a http_arg_value type to house all the values for a given key.

Adjust existing get_arg(s) methods, and add some get_arg_flat type
methods that still just return the first value for a given key.

Add a test case for multiple valued keys.

Add a test case for a large file upload that triggers chunking behavior
of MHD. This causes the server to concatenate file chunks within the
first value of the given arg key, so the test ensures that this
behavior is not affected by the changes.
@stuart-byma
Copy link
Contributor Author

Some auto checks were cancelled? Never seen that before!

@etr
Copy link
Owner

etr commented Mar 7, 2023

Some auto checks were cancelled? Never seen that before!

I suspect that github has finally deprecated ubuntu 18.04 - I've started noticing this issue elsewhere as well. I think we can ignore that check for the purpose of this PR.

This change allows the server to handle argument keys with multiple values
e.g. url?arg=param&arg=what

Previous, the arg key would just be overwritten with the next value. This
change adds a http_arg_value type to house all the values for a given key.

Adjust existing get_arg(s) methods, and add some get_arg_flat type
methods that still just return the first value for a given key.

Add a test case for multiple valued keys.

Add a test case for a large file upload that triggers chunking behavior
of MHD. This causes the server to concatenate file chunks within the
first value of the given arg key, so the test ensures that this
behavior is not affected by the changes.
This change allows the server to handle argument keys with multiple values
e.g. url?arg=param&arg=what

Previous, the arg key would just be overwritten with the next value. This
change adds a http_arg_value type to house all the values for a given key.

Adjust existing get_arg(s) methods, and add some get_arg_flat type
methods that still just return the first value for a given key.

Add a test case for multiple valued keys.

Add a test case for a large file upload that triggers chunking behavior
of MHD. This causes the server to concatenate file chunks within the
first value of the given arg key, so the test ensures that this
behavior is not affected by the changes.
This change allows the server to handle argument keys with multiple values
e.g. url?arg=param&arg=what

Previous, the arg key would just be overwritten with the next value. This
change adds a http_arg_value type to house all the values for a given key.

Adjust existing get_arg(s) methods, and add some get_arg_flat type
methods that still just return the first value for a given key.

Add a test case for multiple valued keys.

Add a test case for a large file upload that triggers chunking behavior
of MHD. This causes the server to concatenate file chunks within the
first value of the given arg key, so the test ensures that this
behavior is not affected by the changes.
**/
class arg_comparator {
public:
using is_transparent = std::true_type;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this doing? (I cannot find it used elsewhere)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required to activate heterogeneous lookup using this comparator. is_transparent just needs to be defined, it doesn't get referenced anywhere. From cppreference:

The member type is_transparent indicates to the caller that this function object is a transparent function object: it accepts arguments of arbitrary types and uses perfect forwarding, which avoids unnecessary copying and conversion when the function object is used in heterogeneous context, or with rvalue arguments. In particular, template functions such as std::set::find and std::set::lower_bound make use of this member type on their Compare types.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh cool. I learned something :). Thank you!

This change allows the server to handle argument keys with multiple values
e.g. url?arg=param&arg=what

Previous, the arg key would just be overwritten with the next value. This
change adds a http_arg_value type to house all the values for a given key.

Adjust existing get_arg(s) methods, and add some get_arg_flat type
methods that still just return the first value for a given key.

Add a test case for multiple valued keys.

Add a test case for a large file upload that triggers chunking behavior
of MHD. This causes the server to concatenate file chunks within the
first value of the given arg key, so the test ensures that this
behavior is not affected by the changes.
@etr etr merged commit 914ac9e into etr:master Mar 8, 2023
@etr
Copy link
Owner

etr commented Mar 8, 2023

Thanks for the change and for the patience to go through the review process. I think this is a great feature to have in the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants