3

I want to get headers which CURL sent to specify URL. I know how to get response headers, but not query headers.

$ch = curl_init();
curl_setopt_array($ch, array(
    CURLOPT_URL => 'https://localhost',
));
$data = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

// Getting response headers
$headers = substr( $data, 0, $info[ "header_size" ] );
if ( substr_count( $headers, "\r\n\r\n" ) > 1 ) {
    $headers = explode( "\r\n\r\n", $headers, -1 );
    $headers = $headers[ sizeof( $headers )-1 ]."\r\n\r\n";
}
SiZE
  • 2,217
  • 1
  • 13
  • 24

0 Answers0