Я пытаюсь получить ответ и заголовки ответов из CURL с помощью PHP, особенно для Content-Disposition: attachment; поэтому я могу вернуть имя файла, переданное в заголовке. Это, похоже, не возвращается в curl_getinfo.
Я попытался использовать HeaderFunction для вызова функции для чтения дополнительных заголовков, однако я не могу добавить содержимое в массив.
Есть ли у кого-нибудь идеи?
Ниже приведена часть моего кода, который является классом оболочки Curl:
...
curl_setopt($this->_ch, CURLOPT_URL, $this->_url);
curl_setopt($this->_ch, CURLOPT_HEADER, false);
curl_setopt($this->_ch, CURLOPT_POST, 1);
curl_setopt($this->_ch, CURLOPT_POSTFIELDS, $this->_postData);
curl_setopt($this->_ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($this->_ch, CURLOPT_USERAGENT, $this->_userAgent);
curl_setopt($this->_ch, CURLOPT_HEADERFUNCTION, 'readHeader');
$this->_response = curl_exec($this->_ch);
$info = curl_getinfo($this->_ch);
...
function readHeader($ch, $header)
{
array_push($this->_headers, $header);
}