$sHeader ) { if( $kHeader == 'Host' ) { continue; } $aHeader[] = "$kHeader: $sHeader"; } curl_setopt ($curlSession, CURLOPT_HTTPHEADER, $aHeader ); if( $_SERVER['REQUEST_METHOD'] == 'POST' ) { $postinfo = ''; foreach( $_POST as $key => $value ) { $postinfo .= $key.'='.urlencode($value).'&'; } rtrim($postinfo,'&'); curl_setopt ($curlSession, CURLOPT_POST, 1); curl_setopt ($curlSession, CURLOPT_POSTFIELDS, $postinfo); }//if Post curl_setopt($curlSession, CURLOPT_RETURNTRANSFER,1); curl_setopt($curlSession, CURLOPT_TIMEOUT,30); curl_setopt($curlSession, CURLOPT_SSL_VERIFYHOST, 1); $myfile = fopen( $ckfile, "w") or die("Unable to open file!"); fclose($myfile); curl_setopt ($curlSession, CURLOPT_COOKIEJAR, $ckfile); curl_setopt ($curlSession, CURLOPT_COOKIEFILE, $ckfile); foreach($_COOKIE as $k=>$v) { if(is_array($v)) { $v = serialize($v); } curl_setopt($curlSession,CURLOPT_COOKIE,"$k=$v; domain=.$cookiedomain ; path=/"); } if( FALSE or false ) // use 2nd as true only if the Agent causes any trouble // { var_dump( curl_getinfo($curlSession) ); exit; } //Send the request and store the result in an array $response = curl_exec ($curlSession); // Check that a connection was made if ( curl_error($curlSession) ) { print '= '.curl_error($curlSession); } else { //clean duplicate header that seems to appear on fastcgi with output buffer on some servers!! $response = str_replace("HTTP/1.1 100 Continue\r\n\r\n","",$response); $a = explode("\r\n\r\n", $response, 2); $header = $a[0]; $body = $a[1]; $aHeader = split(chr(10),$header); foreach( $aHeader as $k => $v ) { if(!preg_match("/^Transfer-Encoding/",$v)) { //$v = str_replace($base,$mydomain,$v); //header rewrite if needed header(trim($v)); } } print $body; } curl_close ($curlSession);