Skip to content

Commit

Permalink
Rather than throwing an Exception, using HttpException to throw a 504…
Browse files Browse the repository at this point in the history
… as seems to fit the description well for a 504: "The server was acting as a gateway or proxy and did not receive a timely response from the upstream server."
  • Loading branch information
ct-owengerrard committed Jul 19, 2017
1 parent c90f9d2 commit d66d089
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Http/Client/Adapter/Stream.php
Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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'];
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Http/Client/Adapter/StreamTest.php
Expand Up @@ -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
*/
Expand Down

0 comments on commit d66d089

Please sign in to comment.