Skip to content

Commit

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

* Skip parameter parsing for raw post body in HTTP Client

* Reduce test string length
  • Loading branch information
Krisell authored and chu121su12 committed May 14, 2022
1 parent c5acd1a commit 539f0ed
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 @@ -932,6 +932,10 @@ protected function sendRequest(/*string */$method, /*string */$url, array $optio
*/
protected function parseRequestData($method, $url, array $options)
{
if ($this->bodyFormat === 'body') {
return [];
}

$laravelData = isset($options[$this->bodyFormat])
? $options[$this->bodyFormat]
: (isset($options['query']) ? $options['query'] : []);
Expand Down
15 changes: 15 additions & 0 deletions tests/Http/HttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,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 539f0ed

Please sign in to comment.