-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add a query string helper from byte cursor directly #1080
Merged
+34
−4
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,7 +212,7 @@ uint16_t aws_uri_port(const struct aws_uri *uri) { | |
return uri->port; | ||
} | ||
|
||
bool aws_uri_query_string_next_param(const struct aws_uri *uri, struct aws_uri_param *param) { | ||
bool aws_query_string_next_param(struct aws_byte_cursor query_string_cursor, struct aws_uri_param *param) { | ||
/* If param is zeroed, then this is the first run. */ | ||
bool first_run = param->value.ptr == NULL; | ||
|
||
|
@@ -230,7 +230,7 @@ bool aws_uri_query_string_next_param(const struct aws_uri *uri, struct aws_uri_p | |
|
||
/* The do-while is to skip over any empty substrings */ | ||
do { | ||
if (!aws_byte_cursor_next_split(&uri->query_string, '&', &substr)) { | ||
if (!aws_byte_cursor_next_split(&query_string_cursor, '&', &substr)) { | ||
/* no more splits, done iterating */ | ||
return false; | ||
} | ||
|
@@ -252,6 +252,22 @@ bool aws_uri_query_string_next_param(const struct aws_uri *uri, struct aws_uri_p | |
return true; | ||
} | ||
|
||
int aws_query_string_params(struct aws_byte_cursor query_string_cursor, struct aws_array_list *out_params) { | ||
struct aws_uri_param param; | ||
AWS_ZERO_STRUCT(param); | ||
while (aws_query_string_next_param(query_string_cursor, ¶m)) { | ||
if (aws_array_list_push_back(out_params, ¶m)) { | ||
return AWS_OP_ERR; | ||
} | ||
} | ||
|
||
return AWS_OP_SUCCESS; | ||
} | ||
|
||
bool aws_uri_query_string_next_param(const struct aws_uri *uri, struct aws_uri_param *param) { | ||
return aws_query_string_next_param(uri->query_string, param); | ||
} | ||
|
||
int aws_uri_query_string_params(const struct aws_uri *uri, struct aws_array_list *out_params) { | ||
struct aws_uri_param param; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if possible, just have aws_uri_query_string_params() call into aws_query_string_params() |
||
AWS_ZERO_STRUCT(param); | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in that other PR how do you plan to go from
path_and_query
to justquery
? Does that necessitate another helper?