$value) { $hdrs[] = "$name: $value"; } // Add captured headers to the request curl_setopt($ch, CURLOPT_HTTPHEADER, $hdrs); // Add POST parameters if (sizeof($_POST) > 0) { curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($_POST)); } // Execute the request $res = curl_exec($ch); // Parse the response list($headers, $body) = explode("\r\n\r\n", $res, 2); $headers = str_replace(static::destinationHost(), '/', $headers); $headers = explode("\r\n", $headers); $hs = []; foreach ($headers as $header) { if (false !== strpos($header, ': ')) { list($h, $v) = explode(': ', $header); $hs[$h][] = $v; } else { $header1 = $header; } } // Define headers in the client list($proto, $code, $text) = explode(' ', $header1); header($_SERVER['SERVER_PROTOCOL'] . ' ' . $code . ' ' . $text); foreach (static::$proxied_headers as $hname) { if (isset($hs[$hname])) { foreach ($hs[$hname] as $v) { if ($hname === 'Set-Cookie') { header($hname . ": " . $v, false); } else { header($hname . ": " . $v); } } } } die(static::apply_filters($body)); } }