I use CURL and PHP to mirror remote web site and it's works fine, but when I try to make POST request with parameters, after CURL received reply from remote server with new "Location:" header, it's not send to user browser (I only see it in curl headers).
I need to redirect user to new location after POST query to remote site. This location received by header reply of remote server, but this not provided to end user browser.
Please help me to find solution. I checked a lot of search engine results with no luck. I only find some advices for command-line curl, but not for PHP.
Thank you!
curl_setopt_array($curl,$x=array(
//CURLOPT_HEADER=>1,
CURLINFO_HEADER_OUT=>1,
CURLOPT_RETURNTRANSFER=>1,
CURLOPT_FOLLOWLOCATION=>true,
CURLOPT_MAXREDIRS=>7,
CURLOPT_AUTOREFERER=>true,
CURLOPT_PROXY=>$proxy,
CURLOPT_PROXYTYPE=>7,
//CURLOPT_COOKIESESSION=>false,
CURLOPT_COOKIEFILE=>$_SESSION['cookie_4'],
CURLOPT_COOKIEJAR=>$_SESSION['cookie_4'],
CURLOPT_REFERER=>$referer,
CURLOPT_ENCODING=>"gzip",
CURLOPT_HTTPHEADER=>array(
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Language: en-US,en;q=0.5",
"Accept-Encoding: gzip, deflate",
"Cache-Control: no-cache",
"Connection: keep-alive",
"Pragma: no-cache",
"Upgrade-Insecure-Requests: 1",
),
CURLOPT_USERAGENT=>/*isset($_SERVER['HTTP_USER_AGENT']) ? (string)$_SERVER['HTTP_USER_AGENT'] : */'Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0',
));
just pass through the headers received by curl to the browser?
curl_setopt($curl,CURLOPT_HEADERFUNCTION,function($ch,$header){
header($header);
return strlen($header);
});