Skip to content

Commit d66d089

Browse files
Rather than throwing an Exception, using HttpException to throw a 504 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."
1 parent c90f9d2 commit d66d089

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Http/Client/Adapter/Stream.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Cake\Core\Exception\Exception;
1717
use Cake\Http\Client\Request;
1818
use Cake\Http\Client\Response;
19+
use Cake\Network\Exception\HttpException;
1920

2021
/**
2122
* Implements sending Cake\Http\Client\Request
@@ -246,7 +247,7 @@ protected function _buildSslContext(Request $request, $options)
246247
*
247248
* @param \Cake\Http\Client\Request $request The request object.
248249
* @return array Array of populated Response objects
249-
* @throws \Cake\Core\Exception\Exception
250+
* @throws \Cake\Network\Exception\HttpException
250251
*/
251252
protected function _send(Request $request)
252253
{
@@ -277,7 +278,7 @@ protected function _send(Request $request)
277278
fclose($this->_stream);
278279

279280
if ($timedOut) {
280-
throw new Exception('Connection timed out ' . $url);
281+
throw new HttpException('Connection timed out ' . $url, 504);
281282
}
282283

283284
$headers = $meta['wrapper_data'];

tests/TestCase/Http/Client/Adapter/StreamTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ public function testKeepDeadline()
423423
/**
424424
* Test that an exception is raised when timed out.
425425
*
426-
* @expectedException \Cake\Core\Exception\Exception
426+
* @expectedException \Cake\Network\Exception\HttpException
427427
* @expectedExceptionMessage Connection timed out http://dummy/?sleep
428428
* @return void
429429
*/

0 commit comments

Comments
 (0)