retesere20

curl-header for some php

Apr 18th, 2021
33
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $headers = [];
  2. if (!empty($curl_opts['headers'])) { //should be callback
  3. $GLOBALS['url_rsp'][md5($url)]=[];
  4. curl_setopt($c, CURLOPT_HEADERFUNCTION, function($curl, $header_line ){
  5. $headers = explode(':', $header_line, 2);
  6. $url=curl_getinfo($curl)['url'];
  7. $GLOBALS['url_rsp'][md5($url)][ trim($headers[0]) ] = !empty($headers[1]) ? trim($headers[1]) : '';
  8. return strlen($header_line);
  9. });
  10. $headers = $GLOBALS['url_rsp'][md5($url)]; //unset($GLOBALS['url_rsp'][md5($url)]);
  11. }
RAW Paste Data