Add download docs
This commit is contained in:
parent
68a7a7d949
commit
5d1ce3b146
@ -97,31 +97,46 @@ class DealProxy
|
||||
CURLOPT_CUSTOMREQUEST => $method,
|
||||
CURLOPT_POSTFIELDS => $body,
|
||||
CURLOPT_HTTPHEADER => $headers,
|
||||
CURLOPT_HEADER => false,
|
||||
CURLOPT_HEADER => true,
|
||||
));
|
||||
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
$verbose = fopen('php://temp', 'w+');
|
||||
curl_setopt($ch, CURLOPT_STDERR, $verbose);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
|
||||
$curlError = curl_error($ch);
|
||||
if ($curlError) {
|
||||
rewind($verbose);
|
||||
$verboseLog = stream_get_contents($verbose);
|
||||
$this->logMessage('cURL VERBOSE: ' . $verboseLog);
|
||||
$this->logMessage('cURL Error: ' . $curlError);
|
||||
} else {
|
||||
$this->logMessage('cURL Response (first 200 chars): ' . substr($response, 0, 200));
|
||||
$this->logMessage('HTTP Code: ' . $httpCode);
|
||||
}
|
||||
curl_close($ch);
|
||||
|
||||
if ($curlError) {
|
||||
$this->logMessage('cURL Error: ' . $curlError);
|
||||
http_response_code(500);
|
||||
echo $curlError;
|
||||
return;
|
||||
}
|
||||
|
||||
$responseHeaders = substr($response, 0, $headerSize);
|
||||
$responseBody = substr($response, $headerSize);
|
||||
|
||||
preg_match_all('/^([^:]+):\s*(.+)$/m', $responseHeaders, $matches);
|
||||
if (isset($matches[1])) {
|
||||
for ($i = 0; $i < count($matches[1]); $i++) {
|
||||
$hName = trim($matches[1][$i]);
|
||||
$hValue = trim($matches[2][$i]);
|
||||
if (strcasecmp($hName, 'Content-Type') === 0 ||
|
||||
strcasecmp($hName, 'Content-Disposition') === 0 ||
|
||||
strcasecmp($hName, 'Content-Length') === 0 ||
|
||||
strcasecmp($hName, 'Content-Transfer-Encoding') === 0 ||
|
||||
strcasecmp($hName, 'Cache-Control') === 0 ||
|
||||
strcasecmp($hName, 'Pragma') === 0) {
|
||||
header("$hName: $hValue");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
http_response_code($httpCode);
|
||||
echo $response;
|
||||
echo $responseBody;
|
||||
}
|
||||
|
||||
private function buildMultipartBody()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user