Wierd fsockopen problem, help?
Posted: Thu Aug 28, 2008 7:56 am
Hello,
Whenever I try to fetch all content from a website using fsockopen I end up in wierd thing.
Here's sample code:
For some reason this is the returned header
Another one:
Headers returned:
What are those wierd things? And the content ended with 0 again:
Whenever I try to fetch all content from a website using fsockopen I end up in wierd thing.
Here's sample code:
Code: Select all
$fp = fsockopen("www.google.fi",80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: http://www.google.fi\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}Wtf is 6ef? Also the website HTML content ends with number 0 ALWAYS...HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Date: Thu, 28 Aug 2008 12:54:13 GMT
Expires: -1
Content-Type: text/html; charset=ISO-8859-1
Set-Cookie: PREF=ID=254a8e3ff08e0e9f:TM=1219928053:LM=1219928053:S=gahRNMEyAykxQ5Xo; expires=Sat, 28-Aug-2010 12:54:13 GMT; path=/; domain=.google.fi
Server: gws
Transfer-Encoding: chunked
Connection: Close
6ef
Another one:
Code: Select all
$fp = fsockopen("www.kaisellgren.name", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: http://www.kaisellgren.name\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}Wtf 698 ?HTTP/1.1 200 OK
Date: Thu, 28 Aug 2008 12:55:08 GMT
Server: Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7a DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
X-Powered-By: PHP/5.2.6
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html
698
What are those wierd things? And the content ended with 0 again:
What's going on?</body>
</html>
0