Skip to content
Permalink
Browse files

Moved creation of HttpClient's response object into a separate method.

  • Loading branch information...
dmromanov committed Nov 4, 2017
1 parent 0d51a48 commit 7215bd35d516cecb0bb420bd27f8ccb216492661
Showing with 15 additions and 2 deletions.
  1. +15 −2 src/Http/Client/Adapter/Stream.php
@@ -90,7 +90,7 @@ public function send(Request $request, array $options)
*
* @param array $headers The list of headers from the request(s)
* @param string $content The response content.
* @return array The list of responses from the request(s)
* @return \Cake\Http\Client\Response[] The list of responses from the request(s)
*/
public function createResponses($headers, $content)
{
@@ -105,7 +105,7 @@ public function createResponses($headers, $content)
$end = isset($indexes[$i + 1]) ? $indexes[$i + 1] - $start : null;
$headerSlice = array_slice($headers, $start, $end);
$body = $i == $last ? $content : '';
$responses[] = new Response($headerSlice, $body);
$responses[] = $this->_buildResponse($headerSlice, $body);
}
return $responses;
@@ -281,6 +281,19 @@ protected function _send(Request $request)
return $this->createResponses($headers, $content);
}
/**
* Build a response object
*
* @param array $headers Unparsed headers.
* @param string $body The response body.
*
* @return \Cake\Http\Client\Response
*/
protected function _buildResponse($headers, $body)
{
return new Response($headers, $body);
}
/**
* Open the socket and handle any connection errors.
*

0 comments on commit 7215bd3

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