RigVan
Постоянный член клуба
броузер подменяет мои "$headers" в Get запросах, что делать?
Проблема в следующем:
мне нужно с localhost отослать GET запрос на один сервер и получить от него ответ...
Для этого я составил следующий скрипт:
<?php
$host = "www.thefreedictionary.com";
$path = "/table";
$fp = fsockopen($host,80,$errno,$errstr,30);
if(!$fp) echo"$errstr ($errno)<br />\n";
else{
$headers = "GET /table HTTP/1.1";
$headers .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; ru) Opera 8.50";
$headers .= "Host: www.thefreedictionary.com";
$headers .= "Accept: application/xhtml+voice+xml;version=1.2, application/x-xhtml+voice+xml;version=1.2, text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1";
$headers .= "Accept-Language: ru, en";
$headers .= "Accept-Charset: windows-1251, utf-8, utf-16, iso-8859-1;q=0.6, *;q=0.1";
$headers .= "Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0";
$headers .= "Connection: Keep-Alive, TE";
$headers .= "TE: deflate, gzip, chunked, identity, trailers";
fwrite($fp,$headers);
while($text != "\r\n") $text = fgets($fp,128);
$text = "";
while(!feof($fp)) $text .= fgets($fp,4096);
fclose($fp);
}
echo $text;
?>
через броузер вызываю скрипт, а он гад, подменяет мои "$headers", и пишет свои:
(Request-Line):GET /mysite/connect.php HTTP/1.1
User-Agent:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; ru) Opera 8.50
Host:localhost
Accept:application/xhtml+voice+xml;version=1.2, application/x-xhtml+voice+xml;version=1.2, text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1
Accept-Language:ru, en
Accept-Charset:windows-1251, utf-8, utf-16, iso-8859-1;q=0.6, *;q=0.1
Accept-Encoding:deflate, gzip, x-gzip, identity, *;q=0
Connection:Keep-Alive
Естественно ни какого ответа от сервера я не получаю. Чего можно сделать ума не приложу
Проблема в следующем:
мне нужно с localhost отослать GET запрос на один сервер и получить от него ответ...
Для этого я составил следующий скрипт:
<?php
$host = "www.thefreedictionary.com";
$path = "/table";
$fp = fsockopen($host,80,$errno,$errstr,30);
if(!$fp) echo"$errstr ($errno)<br />\n";
else{
$headers = "GET /table HTTP/1.1";
$headers .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; ru) Opera 8.50";
$headers .= "Host: www.thefreedictionary.com";
$headers .= "Accept: application/xhtml+voice+xml;version=1.2, application/x-xhtml+voice+xml;version=1.2, text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1";
$headers .= "Accept-Language: ru, en";
$headers .= "Accept-Charset: windows-1251, utf-8, utf-16, iso-8859-1;q=0.6, *;q=0.1";
$headers .= "Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0";
$headers .= "Connection: Keep-Alive, TE";
$headers .= "TE: deflate, gzip, chunked, identity, trailers";
fwrite($fp,$headers);
while($text != "\r\n") $text = fgets($fp,128);
$text = "";
while(!feof($fp)) $text .= fgets($fp,4096);
fclose($fp);
}
echo $text;
?>
через броузер вызываю скрипт, а он гад, подменяет мои "$headers", и пишет свои:
(Request-Line):GET /mysite/connect.php HTTP/1.1
User-Agent:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; ru) Opera 8.50
Host:localhost
Accept:application/xhtml+voice+xml;version=1.2, application/x-xhtml+voice+xml;version=1.2, text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1
Accept-Language:ru, en
Accept-Charset:windows-1251, utf-8, utf-16, iso-8859-1;q=0.6, *;q=0.1
Accept-Encoding:deflate, gzip, x-gzip, identity, *;q=0
Connection:Keep-Alive
Естественно ни какого ответа от сервера я не получаю. Чего можно сделать ума не приложу

