Reputation: 685
I have a Zend\Http\Client with a Zend\Http\Client\Adapter\Curl and want to set a custom header to the adapter. But in the curl adapter there is an array called invalidOverwritableCurlOptions
which includes the CURLOPT_HTTPHEADER
. So it is impossible for me to set that header.
Is there another way to set it?
$adapter = new Curl();
$client = new Client();
$adapter->setCurlOption(CURLOPT_HTTPHEADER, [
'AuthenticationToken:123456'
]);
$client->setAdapter($adapter);
If I comment out the line, where the curl options get validated, everything works fine...
// set additional curl options
if (isset($this->config['curloptions'])) {
foreach ((array) $this->config['curloptions'] as $k => $v) {
//if (! in_array($k, $this->invalidOverwritableCurlOptions)) {
if (curl_setopt($this->curl, $k, $v) == false) {
throw new AdapterException\RuntimeException(sprintf(
'Unknown or erroreous cURL option "%s" set',
$k
));
}
//}
}
}
Upvotes: 0
Views: 369
Reputation: 685
Ok i got it. You can set headers dirctly to the client.
$client->setHeaders([
'AuthenticationToken:123456'
]);
Upvotes: 2