protected function _send(Request $request)
    {
        $deadline = false;
        if (isset($this->_contextOptions['timeout']) && $this->_contextOptions['timeout'] > 0) {
            $deadline = time() + $this->_contextOptions['timeout'];
        }

        $url = $request->getUri();
        $this->_open($url);
        $content = '';
        $timedOut = false;

        while (!feof($this->_stream)) {
            if ($deadline !== false) {
                stream_set_timeout($this->_stream, max($deadline - time(), 1));
            }

            $content .= fread($this->_stream, 8192);

            $meta = stream_get_meta_data($this->_stream);
            if ($meta['timed_out'] || ($deadline !== false && time() > $deadline)) {
                $timedOut = true;
                break;
            }
        }
        $meta = stream_get_meta_data($this->_stream);
        fclose($this->_stream);

        if ($timedOut) {
            throw new HttpException('Connection timed out ' . $url, 504);
        }

        $headers = $meta['wrapper_data'];
        if (isset($headers['headers']) && is_array($headers['headers'])) {
            $headers = $headers['headers'];
        }

        return $this->createResponses($headers, $content);
    }
protected function _send(Request $request)
    {
        $deadline = false;
        if (isset($this->_contextOptions['timeout']) && $this->_contextOptions['timeout'] > 0) {
            $deadline = time() + $this->_contextOptions['timeout'];
        }

        $url = $request->getUri();
        $this->_open($url);
        $content = '';
        $timedOut = false;

        while (!feof($this->_stream)) {
            if ($deadline !== false) {
                stream_set_timeout($this->_stream, max($deadline - time(), 1));
            }

            $content .= fread($this->_stream, 8192);

            $meta = stream_get_meta_data($this->_stream);
            if ($meta['timed_out'] || ($deadline !== false && time() > $deadline)) {
                $timedOut = true;
                break;
            }
        }
        $meta = stream_get_meta_data($this->_stream);
        fclose($this->_stream);

        if ($timedOut) {
            throw new HttpException('Connection timed out ' . $url, 504);
        }

        $headers = $meta['wrapper_data'];
        if (isset($headers['headers']) && is_array($headers['headers'])) {
            $headers = $headers['headers'];
        }

        return $this->createResponses($headers, $content);
    }
protected function _send ( Request $ request ) { $ deadline = false ; if ( isset ( $ this -> _contextOptions [ 'timeout' ] ) && $ this -> _contextOptions [ 'timeout' ] > 0 ) { $ deadline = time ( ) + $ this -> _contextOptions [ 'timeout' ] ; } $ url = $ request -> getUri ( ) ; $ this -> _open ( $ url ) ; $ content = '' ; $ timedOut = false ; while ( ! feof ( $ this -> _stream ) ) { if ( $ deadline !== false ) { stream_set_timeout ( $ this -> _stream , max ( $ deadline - time ( ) , 1 ) ) ; } $ content .= fread ( $ this -> _stream , 8192 ) ; $ meta = stream_get_meta_data ( $ this -> _stream ) ; if ( $ meta [ 'timed_out' ] || ( $ deadline !== false && time ( ) > $ deadline ) ) { $ timedOut = true ; break ; } } $ meta = stream_get_meta_data ( $ this -> _stream ) ; fclose ( $ this -> _stream ) ; if ( $ timedOut ) { throw new HttpException ( 'Connection timed out ' . $ url , 504 ) ; } $ headers = $ meta [ 'wrapper_data' ] ; if ( isset ( $ headers [ 'headers' ] ) && is_array ( $ headers [ 'headers' ] ) ) { $ headers = $ headers [ 'headers' ] ; } return $ this -> createResponses ( $ headers , $ content ) ; }
Open the stream and send the request.

@param \Cake\Http\Client\Request $request The request object.
@return array Array of populated Response objects
@throws \Cake\Http\Exception\HttpException
Open the stream and send the request .