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

Unable to set query parameter to "0" on request #1320

Open
IGx89 opened this issue Oct 11, 2017 · 1 comment
Open

Unable to set query parameter to "0" on request #1320

IGx89 opened this issue Oct 11, 2017 · 1 comment

Comments

@IGx89
Copy link

IGx89 commented Oct 11, 2017

Hello! A bit stumped. I'm using lithium\net\http\Request class and trying to build a request like such:

http://www.test.com/test.php?type=0

When I create the Request with a "query" array with a key of "type" and value of "0" though, the URL sent to curl ends up being just http://www.test.com/test.php.

Digging through the code I found the culprit: the query array is being filtered with array_filter in the queryString method, which removes all query parameters with falsy values! Thus a query parameter containing a single string character of "0" is stripped out.

Is this a bug? Any recommendations on how to work around it?

Thanks!

@mariuswilms
Copy link
Member

mariuswilms commented Feb 3, 2018

Thanks for opening the issue.

I guess you're looking at one of the many array_filter() uses in:

The corresponding tests are here:

At a first look I can't see why the query string is being filtered (even multiple times). The above tests don't seem to cover that case, so I'm tempted to assume we can remove the filtering altogether.

I'd need your help on this: can you try and verify that assumption? Maybe even provide a patch that fixes this seemingly strange behavior?

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

No branches or pull requests

2 participants