mirror of
https://github.com/guzzle/guzzle.git
synced 2025-02-24 01:53:58 +01:00
Force form_params to use & as fields separator
This commit is contained in:
parent
a8dfeff00e
commit
8114c93801
@ -289,7 +289,7 @@ class Client implements ClientInterface
|
||||
. 'x-www-form-urlencoded requests, and the multipart '
|
||||
. 'option to send multipart/form-data requests.');
|
||||
}
|
||||
$options['body'] = http_build_query($options['form_params']);
|
||||
$options['body'] = http_build_query($options['form_params'], null, '&');
|
||||
unset($options['form_params']);
|
||||
$options['_conditional']['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||
}
|
||||
|
@ -410,6 +410,27 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testFormParamsEncodedProperly()
|
||||
{
|
||||
$separator = ini_get('arg_separator.output');
|
||||
ini_set('arg_separator.output', '&');
|
||||
$mock = new MockHandler([new Response()]);
|
||||
$client = new Client(['handler' => $mock]);
|
||||
$client->post('http://foo.com', [
|
||||
'form_params' => [
|
||||
'foo' => 'bar bam',
|
||||
'baz' => ['boo' => 'qux']
|
||||
]
|
||||
]);
|
||||
$last = $mock->getLastRequest();
|
||||
$this->assertEquals(
|
||||
'foo=bar+bam&baz%5Bboo%5D=qux',
|
||||
(string) $last->getBody()
|
||||
);
|
||||
|
||||
ini_set('arg_separator.output', $separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user