From a9d6353612b44254d0c0e76679f401c4db1769a8 Mon Sep 17 00:00:00 2001 From: Joel Wurtz Date: Fri, 29 Jan 2016 01:37:39 +0100 Subject: [PATCH] Add missing transfer encoding header for chunked --- CHANGELOG.md | 5 +++++ spec/ContentLengthPluginSpec.php | 1 + src/ContentLengthPlugin.php | 1 + 3 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eeb6c45..233e4d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 1.0.1 - 2016-01-29 + +### Changed + + - Set the correct header for the Content-Length when in chunked mode. ## 1.0.0 - 2016-01-28 diff --git a/spec/ContentLengthPluginSpec.php b/spec/ContentLengthPluginSpec.php index 18bf1e0..0fa463f 100644 --- a/spec/ContentLengthPluginSpec.php +++ b/spec/ContentLengthPluginSpec.php @@ -37,6 +37,7 @@ function it_streams_chunked_if_no_size(RequestInterface $request, StreamInterfac $stream->getSize()->shouldBeCalled()->willReturn(null); $request->withBody(Argument::type('Http\Message\Encoding\ChunkStream'))->shouldBeCalled()->willReturn($request); + $request->withAddedHeader('Transfer-Encoding', 'chunked')->shouldBeCalled()->willReturn($request); $this->handleRequest($request, function () {}, function () {}); } diff --git a/src/ContentLengthPlugin.php b/src/ContentLengthPlugin.php index 843f524..068d65e 100644 --- a/src/ContentLengthPlugin.php +++ b/src/ContentLengthPlugin.php @@ -24,6 +24,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl if (null === $stream->getSize()) { $stream = new ChunkStream($stream); $request = $request->withBody($stream); + $request = $request->withAddedHeader('Transfer-Encoding', 'chunked'); } else { $request = $request->withHeader('Content-Length', $stream->getSize()); }