Initialize $curlOptions[CURLOPT_HTTPHEADER] outside of the checks
This commit is contained in:
parent
c3eca0cfae
commit
ff2d85b703
1 changed files with 4 additions and 11 deletions
|
@ -116,17 +116,13 @@ class HTTPRequest implements IHTTPRequest
|
||||||
// $curlOptions[CURLOPT_FOLLOWLOCATION] =true;
|
// $curlOptions[CURLOPT_FOLLOWLOCATION] =true;
|
||||||
// $curlOptions[CURLOPT_MAXREDIRS] = 5;
|
// $curlOptions[CURLOPT_MAXREDIRS] = 5;
|
||||||
|
|
||||||
if (!empty($opts['accept_content'])) {
|
|
||||||
if (empty($curlOptions[CURLOPT_HTTPHEADER])) {
|
|
||||||
$curlOptions[CURLOPT_HTTPHEADER] = [];
|
$curlOptions[CURLOPT_HTTPHEADER] = [];
|
||||||
}
|
|
||||||
|
if (!empty($opts['accept_content'])) {
|
||||||
array_push($curlOptions[CURLOPT_HTTPHEADER], 'Accept: ' . $opts['accept_content']);
|
array_push($curlOptions[CURLOPT_HTTPHEADER], 'Accept: ' . $opts['accept_content']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($opts['header'])) {
|
if (!empty($opts['header'])) {
|
||||||
if (empty($curlOptions[CURLOPT_HTTPHEADER])) {
|
|
||||||
$curlOptions[CURLOPT_HTTPHEADER] = [];
|
|
||||||
}
|
|
||||||
$curlOptions[CURLOPT_HTTPHEADER] = array_merge($opts['header'], $curlOptions[CURLOPT_HTTPHEADER]);
|
$curlOptions[CURLOPT_HTTPHEADER] = array_merge($opts['header'], $curlOptions[CURLOPT_HTTPHEADER]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,9 +142,6 @@ class HTTPRequest implements IHTTPRequest
|
||||||
|
|
||||||
if (!empty($opts['headers'])) {
|
if (!empty($opts['headers'])) {
|
||||||
$this->logger->notice('Wrong option \'headers\' used.');
|
$this->logger->notice('Wrong option \'headers\' used.');
|
||||||
if (empty($curlOptions[CURLOPT_HTTPHEADER])) {
|
|
||||||
$curlOptions[CURLOPT_HTTPHEADER] = [];
|
|
||||||
}
|
|
||||||
$curlOptions[CURLOPT_HTTPHEADER] = array_merge($opts['headers'], $curlOptions[CURLOPT_HTTPHEADER]);
|
$curlOptions[CURLOPT_HTTPHEADER] = array_merge($opts['headers'], $curlOptions[CURLOPT_HTTPHEADER]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue