diff --git a/spec/Plugin/ContentLengthPluginSpec.php b/spec/Plugin/ContentLengthPluginSpec.php index 75e913e..4ec2ba7 100644 --- a/spec/Plugin/ContentLengthPluginSpec.php +++ b/spec/Plugin/ContentLengthPluginSpec.php @@ -25,7 +25,7 @@ function it_adds_content_length_header(RequestInterface $request, StreamInterfac $request->hasHeader('Content-Length')->shouldBeCalled()->willReturn(false); $request->getBody()->shouldBeCalled()->willReturn($stream); $stream->getSize()->shouldBeCalled()->willReturn(100); - $request->withHeader('Content-Length', 100)->shouldBeCalled()->willReturn($request); + $request->withHeader('Content-Length', '100')->shouldBeCalled()->willReturn($request); $this->handleRequest($request, function () {}, function () {}); } diff --git a/src/Plugin/ContentLengthPlugin.php b/src/Plugin/ContentLengthPlugin.php index a740c19..0f7aafa 100644 --- a/src/Plugin/ContentLengthPlugin.php +++ b/src/Plugin/ContentLengthPlugin.php @@ -27,7 +27,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl $request = $request->withBody($stream); $request = $request->withAddedHeader('Transfer-Encoding', 'chunked'); } else { - $request = $request->withHeader('Content-Length', $stream->getSize()); + $request = $request->withHeader('Content-Length', (string) $stream->getSize()); } }