hi boys,
I am willing to write a kind of proxy in php and I have a problem with raw http connections and their outputs ( I first used fopen() with remote files but I couldn't really do what I wanted with it)
here's a sample code, supposed to get a file on a server and display it on my browser :
<?
$f = fsockopen("somehost.com",80);
fputs($f,"GET /some.file HTTP/1.0\n\n");
while(!feof($f)) {
$output .= fgets($f,2000);
}
fclose($f);
eregi("(.)\r\n\r\n(.)", $output, $result);
header($result[1]);
echo $result[2];
?>
Can someone tell me what's wrong with it ? I get an error 500 everytime I try it. I know an answer to a GET request is a bunch of headers, then a blank line, then the data itself. So I suppose the reg.exp is ok. But then ?
Thanks for looking at my problem .. and eventually solve it =)
Greuh !