Skip to content

Commit

Permalink
Fix form content encoding
Browse files Browse the repository at this point in the history
Co-authored-by: Bilge <bilge@scriptfusion.com>
  • Loading branch information
kelunik and Bilge committed Aug 5, 2023
1 parent 29513c8 commit 4a962fe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private function generateFormEncodedBody(): string
}
}

return QueryString::build($pairs) ?? '';
return QueryString::build($pairs, '&', \PHP_QUERY_RFC1738) ?? '';
}

/**
Expand Down
3 changes: 2 additions & 1 deletion test/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4a962fe

Please sign in to comment.