Skip to content

Commit a7d9174

Browse files
committed
Throw when buffer rejects
1 parent 6013081 commit a7d9174

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

src/Middleware/RequestBodyBufferMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function __invoke(ServerRequestInterface $request, $stack)
5353
return new Response(413, array('Content-Type' => 'text/plain'), 'Request body exceeds allowed limit');
5454
}
5555

56-
return new Response(400, array('Content-Type' => 'text/plain'), $error->getMessage());
56+
throw $error;
5757
});
5858
}
5959

tests/Middleware/RequestBodyBufferMiddlewareTest.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ function($response) use (&$exposedResponse) {
124124
Block\await($promise, $loop);
125125
}
126126

127+
/**
128+
* @expectedException RuntimeException
129+
*/
127130
public function testBufferingErrorReturnsError400()
128131
{
129132
$loop = Factory::create();
@@ -146,16 +149,6 @@ function (ServerRequestInterface $request) {
146149

147150
$stream->emit('error', array(new \RuntimeException()));
148151

149-
$exposedResponse = null;
150-
$promise->then(
151-
function($response) use (&$exposedResponse) {
152-
$exposedResponse = $response;
153-
},
154-
$this->expectCallableNever()
155-
);
156-
157-
$this->assertSame(400, $exposedResponse->getStatusCode());
158-
159152
Block\await($promise, $loop);
160153
}
161154
}

0 commit comments

Comments
 (0)