forked from loafle/openapi-generator-original
add debug switch to print out downloaded file info
This commit is contained in:
@@ -55,18 +55,21 @@ class ApiClient
|
||||
|
||||
/**
|
||||
* Configuration
|
||||
*
|
||||
* @var Configuration
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* Object Serializer
|
||||
*
|
||||
* @var ObjectSerializer
|
||||
*/
|
||||
protected $serializer;
|
||||
|
||||
/**
|
||||
* Constructor of the class
|
||||
*
|
||||
* @param Configuration $config config for this ApiClient
|
||||
*/
|
||||
public function __construct(\Swagger\Client\Configuration $config = null)
|
||||
@@ -81,6 +84,7 @@ class ApiClient
|
||||
|
||||
/**
|
||||
* Get the config
|
||||
*
|
||||
* @return Configuration
|
||||
*/
|
||||
public function getConfig()
|
||||
@@ -90,6 +94,7 @@ class ApiClient
|
||||
|
||||
/**
|
||||
* Get the serializer
|
||||
*
|
||||
* @return ObjectSerializer
|
||||
*/
|
||||
public function getSerializer()
|
||||
@@ -99,7 +104,9 @@ class ApiClient
|
||||
|
||||
/**
|
||||
* Get API key (with prefix if set)
|
||||
*
|
||||
* @param string $apiKeyIdentifier name of apikey
|
||||
*
|
||||
* @return string API key with the prefix
|
||||
*/
|
||||
public function getApiKeyWithPrefix($apiKeyIdentifier)
|
||||
@@ -122,12 +129,14 @@ class ApiClient
|
||||
|
||||
/**
|
||||
* Make the HTTP call (Sync)
|
||||
*
|
||||
* @param string $resourcePath path to method endpoint
|
||||
* @param string $method method to call
|
||||
* @param array $queryParams parameters to be place in query URL
|
||||
* @param array $postData parameters to be placed in POST body
|
||||
* @param array $headerParams parameters to be place in request header
|
||||
* @param string $responseType expected response type of the endpoint
|
||||
*
|
||||
* @throws \Swagger\Client\ApiException on a non 2xx response
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -160,7 +169,7 @@ class ApiClient
|
||||
if ($this->config->getCurlTimeout() != 0) {
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, $this->config->getCurlTimeout());
|
||||
}
|
||||
// return the result on success, rather than just true
|
||||
// return the result on success, rather than just true
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||
@@ -171,7 +180,7 @@ class ApiClient
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
}
|
||||
|
||||
if (! empty($queryParams)) {
|
||||
if (!empty($queryParams)) {
|
||||
$url = ($url . '?' . http_build_query($queryParams));
|
||||
}
|
||||
|
||||
@@ -216,7 +225,7 @@ class ApiClient
|
||||
// Make the request
|
||||
$response = curl_exec($curl);
|
||||
$http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
|
||||
$http_header = $this->http_parse_headers(substr($response, 0, $http_header_size));
|
||||
$http_header = $this->httpParseHeaders(substr($response, 0, $http_header_size));
|
||||
$http_body = substr($response, $http_header_size);
|
||||
$response_info = curl_getinfo($curl);
|
||||
|
||||
@@ -295,16 +304,16 @@ class ApiClient
|
||||
*
|
||||
* @return string[] Array of HTTP response heaers
|
||||
*/
|
||||
protected function http_parse_headers($raw_headers)
|
||||
protected function httpParseHeaders($raw_headers)
|
||||
{
|
||||
// ref/credit: http://php.net/manual/en/function.http-parse-headers.php#112986
|
||||
$headers = array();
|
||||
$key = '';
|
||||
|
||||
|
||||
foreach(explode("\n", $raw_headers) as $h)
|
||||
{
|
||||
$h = explode(':', $h, 2);
|
||||
|
||||
|
||||
if (isset($h[1]))
|
||||
{
|
||||
if (!isset($headers[$h[0]]))
|
||||
@@ -317,18 +326,18 @@ class ApiClient
|
||||
{
|
||||
$headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1])));
|
||||
}
|
||||
|
||||
|
||||
$key = $h[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (substr($h[0], 0, 1) == "\t")
|
||||
$headers[$key] .= "\r\n\t".trim($h[0]);
|
||||
if (substr($h[0], 0, 1) == "\t")
|
||||
$headers[$key] .= "\r\n\t".trim($h[0]);
|
||||
elseif (!$key)
|
||||
$headers[0] = trim($h[0]);trim($h[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $headers;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user