Skip to content

Commit 939cda5

Browse files
committed
fix(http-client-mock): add content-length to body
1 parent 5638731 commit 939cda5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/HttpClientMock/MockRequestBuilderFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,14 @@ private function processBody(
5757
array $headers,
5858
): void {
5959
$contentType = (string) $mockRequestBuilder->getHeader('Content-Type');
60+
$contentLength = $mockRequestBuilder->getHeader('Content-Length') ?? 0;
6061

6162
// application/json; charset=utf-8
6263
if (strpos($contentType, 'application/json') === 0) {
6364
if (is_string($body)) {
6465
$mockRequestBuilder->json(json_decode($body, true));
6566
} elseif (is_callable($body)) {
66-
$mockRequestBuilder->json(json_decode((string) $body(), true));
67+
$mockRequestBuilder->json(json_decode((string) $body((int) $contentLength), true));
6768
} elseif (is_array($body)) {
6869
$mockRequestBuilder->json($body);
6970
} else {

0 commit comments

Comments
 (0)