Skip to content
Permalink
Browse files

Close connection before throwing exception

  • Loading branch information...
chinpei215 committed May 31, 2016
1 parent e5c4979 commit 5b05db69deebfeebc07fb3e3a8bd2148e585f35c
Showing with 7 additions and 1 deletion.
  1. +7 −1 src/Network/Http/Adapter/Stream.php
@@ -265,6 +265,7 @@ protected function _send(Request $request)
$url = $request->url();
$this->_open($url);
$content = '';
$timedOut = false;
while (!feof($this->_stream)) {
if ($deadline !== false) {
@@ -275,12 +276,17 @@ protected function _send(Request $request)
$meta = stream_get_meta_data($this->_stream);
if ($meta['timed_out'] || ($deadline !== false && time() > $deadline)) {
throw new Exception('Connection timed out ' . $url);
$timedOut = true;
break;
}
}
$meta = stream_get_meta_data($this->_stream);
fclose($this->_stream);
if ($timedOut) {
throw new Exception('Connection timed out ' . $url);
}
$headers = $meta['wrapper_data'];
if (isset($headers['headers']) && is_array($headers['headers'])) {
$headers = $headers['headers'];

0 comments on commit 5b05db6

Please sign in to comment.
You can’t perform that action at this time.