Skip to content
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

Request.GET drops empty params #436

Closed
sk- opened this issue Jul 10, 2015 · 9 comments
Closed

Request.GET drops empty params #436

sk- opened this issue Jul 10, 2015 · 9 comments
Labels

Comments

@sk-
Copy link

sk- commented Jul 10, 2015

Currently Request.GET drops empty params. That is if the path is /get?foo=&bar, I won't be able to see either foo or bar

This could be fixed by adding keep_blank_valus=True to parse_qsl in Request.GET, just like it is done for Request.post.

@asvetlov
Copy link
Member

See also #388

@fafhrd91
Copy link
Member

maybe keep_blank_valus=True should be default? what does pyramid do for blank values?

@sk-
Copy link
Author

sk- commented Jul 10, 2015

Why is False a reasonable default for keep_blank_values in the GET method and True a reasonable default in the post method?

We should at least be consistent.

Pyramid does return the empty params. See parse_qsl_text in https://github.com/Pylons/webob/blob/master/webob/compat.py#L103.

@asvetlov
Copy link
Member

I'm inclined to making keep_blank_values=True without providing a way to change new behavior.

@kxepal
Copy link
Member

kxepal commented Jul 10, 2015

@sk-
What's the use case for empty query params? If value doesn't matter, why not accept any? Especially if RFC clearly defines query part as carrying identifying information in the form of "key=value" pairs. Keyword pairs.

The use case of empty params for POST is HTML form submission where not all the fields may be filled by user.

@asvetlov
Copy link
Member

@kxepal I may want to pass empty string for parameter

@sk-
Copy link
Author

sk- commented Jul 10, 2015

The same could be argued then for GET, you can also have forms using get (like search forms). In that case, the value is the empty string ?key= (I'm not that concerned about the alternative without the = sign, ?key).

If you not allow the case ?key=, then how would you express that the value is empty?

Note also, that the RFC does not specify any format for the query string. It says:
... query components are often used to carry identifying information in the form of "key=value" pairs .... See https://tools.ietf.org/html/rfc3986#section-3.4

In my particular use case I'm not checking for presence in which any value could do the trick. Rather I have a middleware that will log the request only if there's a specific field set (It could be empty).

@asvetlov
Copy link
Member

Done.
I believe it doesn't bring backward incompatibilities.

@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants