diff --git a/src/IPub/Flickr/Api/CurlClient.php b/src/IPub/Flickr/Api/CurlClient.php index 368b530..03f49e3 100644 --- a/src/IPub/Flickr/Api/CurlClient.php +++ b/src/IPub/Flickr/Api/CurlClient.php @@ -135,14 +135,7 @@ public function makeRequest(Request $request) } } - $info = curl_getinfo($ch); - $info['http_code'] = (int) $info['http_code']; - if (isset($info['request_header'])) { - list($info['request_header']) = self::parseHeaders($info['request_header']); - } - $info['method'] = $request->getMethod() ? $request->getMethod() : 'GET'; - $info['headers'] = self::parseHeaders(substr($result, 0, $info['header_size'])); - $info['error'] = $result === FALSE ? ['message' => curl_error($ch), 'code' => curl_errno($ch)] : []; + $info = $this->getRequestInfo($ch, $request, $result); if (isset($info['request_header'])) { $request->setHeaders($info['request_header']); @@ -224,4 +217,25 @@ private static function parseHeaders($raw) return $headers; } + + /** + * @param $ch + * @param Request $request + * @param $result + * + * @return array + */ + private function getRequestInfo($ch, Request $request, $result) + { + $info = curl_getinfo($ch); + $info['http_code'] = (int) $info['http_code']; + if (isset($info['request_header'])) { + list($info['request_header']) = self::parseHeaders($info['request_header']); + } + $info['method'] = $request->getMethod() ? $request->getMethod() : 'GET'; + $info['headers'] = self::parseHeaders(substr($result, 0, $info['header_size'])); + $info['error'] = $result === FALSE ? ['message' => curl_error($ch), 'code' => curl_errno($ch)] : []; + + return $info; + } } \ No newline at end of file