-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
How to sent empty parameters #973
Comments
There are two different ways to do this:
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client();
$request = $client->createRequest('GET', 'http://httpbin.org/get', [
'query' => [
'foo' => 'bar',
'baz' => '', // sends trailing =
'qux' => null // no trailing =
]
]);
echo $request->getUrl(); Outputs: |
thanks @mtdowling |
And what about POST request? It should be always with trailing =. |
@mtdowling When I set |
I had the same issue as @simPod said. Can we add some docs for this behavior? |
Same issue... Any idea ? :) Line 371 in 7bc46be
|
Having the same issue right now
The parameter |
Hi, is there any work around with this issue? |
It seems, you have to build the query string manually (in <?php
require_once dirname(__FILE__) . '/../bootstrap.php';
use GuzzleHttp\Client;
$query = join('&', [
http_build_query(
[
'foo' => 'bar',
'baz' => '', // sends trailing =
],
null, '&', PHP_QUERY_RFC3986
),
'qux', // no trailing =
]);
echo $query . PHP_EOL; // foo=bar&baz=&qux
$client = new Client();
$response = $client->get("https://httpbin.org/get", ['query' => $query]);
echo $response->getBody(); since AFAIK neither Guzzle nor http_build_query support query parameters without value and no trailing
|
I'm having trouble with a site I need pass empty arguments on the query. example:
http://thehost.com?Subject=Hello+World&submit=
i trying to make
but guzzle trim the submit parameter, how can solve this issue?
The text was updated successfully, but these errors were encountered: