Skip to content
This repository has been archived by the owner on Feb 17, 2020. It is now read-only.

Commit

Permalink
- Code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
akadlec committed Feb 28, 2015
1 parent bb8155c commit 937f22f
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/IPub/Flickr/Api/CurlClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 937f22f

Please sign in to comment.