From 4a962fe1d96ca0ca956401f08eb3eb72e90e5d2b Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Sat, 5 Aug 2023 17:21:21 +0200 Subject: [PATCH] Fix form content encoding Co-authored-by: Bilge --- src/Form.php | 2 +- test/FormTest.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Form.php b/src/Form.php index b7b6d8b4..3c6aa865 100644 --- a/src/Form.php +++ b/src/Form.php @@ -165,7 +165,7 @@ private function generateFormEncodedBody(): string } } - return QueryString::build($pairs) ?? ''; + return QueryString::build($pairs, '&', \PHP_QUERY_RFC1738) ?? ''; } /** diff --git a/test/FormTest.php b/test/FormTest.php index e8d184fc..af792222 100644 --- a/test/FormTest.php +++ b/test/FormTest.php @@ -14,9 +14,10 @@ public function testUrlEncoded(): void $body->addField('b', 'b', 'application/json'); $body->addField('c', 'c', ''); $body->addField('d', 'd'); + $body->addField('encoding', '1+2'); $content = buffer($body->getContent()); - $this->assertEquals("a=a&b=b&c=c&d=d", $content); + $this->assertEquals("a=a&b=b&c=c&d=d&encoding=1%2B2", $content); } public function testMultiPartFieldsStream(): void