View Full Version : What does the HOST refer to in the header section of a request?

03-17-2003, 01:27 PM
Hi, when I use fsockopen, I should enter the URL or the IP of the server that I want to open.

Something like this:

$fp = fsockopen("$URL", 80);

After openning the connection, I need to make a request. The request is something like this:

$Request = "GET /index.html HTTP/1.0\r\n" .
"HOST: www.ASite.com\r\n\r\n";

So, here is my question: What does this HOST mean in our request?
Is this the URL of the server that we are connectiong to ( in this case it should be $URL ), or is it the URL that we're comming from? Because as we know we can use $HTTP_SERVER_VARS["REMOTE_ADDR"] in a page to get the IP of the viewer. So, by requesting a page in this way, we should somehow tell the responding server where we are comming from; maybe they're using the same way to get the URL that redirected us to their page. But if it's not, how could the responding server find out our IP or URL that redirected us to it?

PS. I checked it out by changing the HOST value to something different with $URL ( as you see ), then I made the script to read a php file that output $HTTP_SERVER_VARS["REMOTE_ADDR"], I expected that this php file shows me "www.ASite.com" ( the thing that I put in my request ), but instead it showed the url that I used in fsockopen ($URL). If it be like this, then the webmaster at the responding server never finds out where we are comming from!

03-18-2003, 02:49 AM
You can put any URL you like as the HOST
but if the script at the other end validates the referer you will need it, but even yak@yak.com should work.

03-19-2003, 12:11 AM
So, you're saying that it is the variable that will make the $_SERVER["REFERER"], right? It means that if I put something like yak@yak.com, then a script at the other end wants to find out where I'm comming from, it'll show yak@yak.com as the referer? So, we can fake a website like this, am I right?