Skip to content

Conversation

c00kiemon5ter
Copy link
Member

A POST request can have a query string. In that case context.request
will hold the data from the POST request body, and thus there is no
place to hold the query params.

With this changeset, a new property is introduced to hold the query
string, parsed as query params. The query params is a list of tuples.
Each tuple holds two elements, the query param name and the query param
value. Params with no value are dropped.

?param_w_value=123&param_w_no_value

All Submissions:

  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Have you added an explanation of what problem you are trying to solve with this PR?
  • Have you added information on what your changes do and why you chose this as your solution?
  • Have you written new tests for your changes?
  • Does your submission pass tests?
  • This project follows PEP8 style guide. Have you run your code against the 'flake8' linter?

@c00kiemon5ter
Copy link
Member Author

@peppelinux would you like to verify that this works as expected?

@@ -128,6 +128,7 @@ def __call__(self, environ, start_response, debug=False):
context.request_uri = environ.get("REQUEST_URI")
context.request_method = environ.get("REQUEST_METHOD")
context.http_headers = collect_http_headers(environ)
context.qs_params = parse_query_string(environ.get("QUERY_STRING"))
Copy link
Member

Choose a reason for hiding this comment

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

ok, it looks good to me in this way

A POST request can have a query string. In that case context.request
will hold the data from the POST request body, and thus there is no
place to hold the query params.

With this changeset, a new property is introduced to hold the query
string, parsed as query params. The query params is a list of tuples.
Each tuple holds two elements, the query param name and the query param
value. Params with no value are dropped.

    ?param_w_value=123&param_w_no_value

Signed-off-by: Ivan Kanakarakis <[email protected]>
@c00kiemon5ter c00kiemon5ter force-pushed the refactor-context-query-params branch from 7eaff80 to b50f70b Compare August 27, 2021 18:54
@c00kiemon5ter c00kiemon5ter changed the title Introduce explicit context property to hold the query params Enhance context properties Aug 27, 2021
@c00kiemon5ter c00kiemon5ter changed the title Enhance context properties Enhance Context object properties Aug 27, 2021
@c00kiemon5ter c00kiemon5ter merged commit 24b4583 into master Aug 27, 2021
@c00kiemon5ter c00kiemon5ter deleted the refactor-context-query-params branch August 27, 2021 19:07
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.

2 participants