Permalink
Browse files

Merge pull request #10926 from ogrrd/master

Throw a 504 when upstream request times out
  • Loading branch information...
markstory committed Jul 19, 2017
2 parents c90f9d2 + d66d089 commit dd51df0e5ba6800c35a81e14dd05d8a19118a43f
Showing with 4 additions and 3 deletions.
  1. +3 −2 src/Http/Client/Adapter/Stream.php
  2. +1 −1 tests/TestCase/Http/Client/Adapter/StreamTest.php
@@ -16,6 +16,7 @@
use Cake\Core\Exception\Exception;
use Cake\Http\Client\Request;
use Cake\Http\Client\Response;
use Cake\Network\Exception\HttpException;
/**
* Implements sending Cake\Http\Client\Request
@@ -246,7 +247,7 @@ protected function _buildSslContext(Request $request, $options)
*
* @param \Cake\Http\Client\Request $request The request object.
* @return array Array of populated Response objects
* @throws \Cake\Core\Exception\Exception
* @throws \Cake\Network\Exception\HttpException
*/
protected function _send(Request $request)
{
@@ -277,7 +278,7 @@ protected function _send(Request $request)
fclose($this->_stream);
if ($timedOut) {
throw new Exception('Connection timed out ' . $url);
throw new HttpException('Connection timed out ' . $url, 504);
}
$headers = $meta['wrapper_data'];
@@ -423,7 +423,7 @@ public function testKeepDeadline()
/**
* Test that an exception is raised when timed out.
*
* @expectedException \Cake\Core\Exception\Exception
* @expectedException \Cake\Network\Exception\HttpException
* @expectedExceptionMessage Connection timed out http://dummy/?sleep
* @return void
*/

0 comments on commit dd51df0

Please sign in to comment.