Skip to content

Commit

Permalink
[9.x] Skip parameter parsing for raw post body in HTTP Client (#42364)
Browse files Browse the repository at this point in the history
* Skip parameter parsing for raw post body in HTTP Client

* Reduce test string length
  • Loading branch information
Krisell authored May 12, 2022
1 parent 9feb9f2 commit 17f1974
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Illuminate/Http/Client/PendingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,10 @@ protected function sendRequest(string $method, string $url, array $options = [])
*/
protected function parseRequestData($method, $url, array $options)
{
if ($this->bodyFormat === 'body') {
return [];
}

$laravelData = $options[$this->bodyFormat] ?? $options['query'] ?? [];

$urlString = Str::of($url);
Expand Down
15 changes: 15 additions & 0 deletions tests/Http/HttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,21 @@ public function testSendRequestBody()
$this->factory->withBody($body, 'application/json')->send('get', 'http://foo.com/api');
}

public function testSendRequestBodyWithManyAmpersands()
{
$body = str_repeat('A thousand &. ', 1000);

$fakeRequest = function (Request $request) use ($body) {
self::assertSame($body, $request->body());

return ['my' => 'response'];
};

$this->factory->fake($fakeRequest);

$this->factory->withBody($body, 'text/plain')->send('post', 'http://foo.com/api');
}

public function testUrlsCanBeStubbedByPath()
{
$this->factory->fake([
Expand Down

0 comments on commit 17f1974

Please sign in to comment.