The PHP cURL wrapper does not expose a way of doing this as far as I know.
Also, cURL will automatically change the Host
header even if you specify a different one.
For example:
curl -v --dump-header - -0 -H 'Host: my-domain.com' http://subdomain.my-domain.com/something.html
will ignore the custom header and send this:
GET /something.html HTTP/1.0
User-Agent: curl/7.35.0
Host: subdomain.my-domain.com
Accept: */*
What you can do is build the request manually:
$host = 'my-domain.com';
$path = 'http://subdomain.my-domain.com/something.html';
$fp = fsockopen($host, 80);
fputs($fp, "GET $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: 0\r\n");
fputs($fp, "Connection: close\r\n\r\n");
$result = '';
while(!feof($fp)) {
$result .= fgets($fp, 128);
}
fclose($fp);
echo $result;