Following what curl does internally for the request (via the method outlined in this answer to “Php – Debugging Curl”) answers the question: No.
No, it is not possible to use curl_setopt(PHP)
with CURLOPT_HTTPHEADER
more than once, passing it a single header each time, in order to set multiple headers.
A second call will overwrite the headers of a previous call (e.g. of the first call).
Instead the function needs to be called once with all headers:
$headers = [
'Content-type: application/xml',
'Authorization: gfhjui',
];
curl_setopt($curlHandle, CURLOPT_HTTPHEADER, $headers);
Related (but different) questions are:
- How to send a header using a HTTP request through a curl call? (curl on the commandline)
- How to get an option previously set with curl_setopt()? (curl PHP extension)