Query value of 0 is removed from request url #108

Closed
dodid opened this Issue Jul 24, 2012 · 4 comments

Comments

Projects
None yet
3 participants

dodid commented Jul 24, 2012

All zeros in the request URL are removed, for example,

$request = $client->get('http://localhost/get?a=0&b=0&c=1'); 
echo $request->getUrl();

output:

http://localhost/get?a=&b=&c=1

mtdowling closed this in bc6cbc8 Jul 24, 2012

dodid commented Jul 24, 2012

Thanks for the quick response. Still fail if query string is passed in as string rather than array.

Owner

mtdowling commented Jul 24, 2012

Thanks for letting me know. Can you give me an example?

On Jul 24, 2012, at 1:46 AM, dodidreply@reply.github.com wrote:

Thanks for the quick response. Still fail if query string is passed in as string rather than array.


Reply to this email directly or view it on GitHub:
#108 (comment)

dodid commented Jul 24, 2012

It fails for the case illustrated in my original issue report.

On line 66 in QueryString.php
            if (empty($parts[1])) {
                $q->add($key, '');
            } else {
                $q->add($key, rawurldecode(str_replace('+', '%20', $parts[1])));
            }

The empty() call returns true for 0, '0', 0.0.

Contributor

davedevelopment commented Jul 24, 2012

I can confirm this, array_key_exists might be a better test

@davedevelopment davedevelopment added a commit to davedevelopment/guzzle that referenced this issue Jul 24, 2012

@davedevelopment davedevelopment Fixes #108 - Check array key exists rather than for empty f0ecc3a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment