Problem with getting a file



I am trying to make afunction to get information from one file and
print it or put it in an array, the problem in headers I can't figure
that it is giving me this:
********
HTTP/1.1 400 Bad Request Date: Fri, 21 Oct 2005 14:48:06 GMT Server:
Apache Connection: close Content-Type: text/html; charset=iso-8859-1
Bad Request
Your browser sent a request that this server could not understand.

Request header field is missing colon separator.

Host=www.imtec.ba
********
My code is :
*********
<?
function getFile($host,$file)
{
$request="GET $file HTTP/1.0\r\n"; // This is the path part of the
link
$request.="Host=$host\r\n\r\n"; // This is the server part of the
link

// Now let's try connecting:
$fp=fsockopen($host, 80, $errno, $errstr, 30);

// Let's see if we made it
if (!$fp)
{
return(false);
}
else
{
// If we made it, let's send the request:
fputs($fp, $request);

while (!feof($fp))
{
$response.=fgets($fp, 128);
}
fclose($fp);
return($response);
}
}
echo getFile("www.imtec.ba","index.php");
?>
*********
Any help, what is wrong..
Thank you

.



Relevant Pages

  • Re: HTTP - basic authentication example.
    ... or *never* knowing the realm..) ... This is called authentication and is implemented ... requests a web page it sends a request to the server. ... consists of headers with certain information about the request. ...
    (comp.lang.python)
  • Re: Is there a way to obtain a Session object other than the current one ?
    ... > have headers, requests and responses do. ... When I said "same headers of the current page" I should have said "the ... When a request for MyImage.gif is sent to the server, ... I (the client control) want to be like the tag. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: HttpWebRequest and Host header (ANSWERED)
    ... However there is a subtle difference in the request ... headers sent with this method, and what the actual request should be ... Host: www.company.com ...
    (microsoft.public.dotnet.framework)
  • Re: Writing a file in Response
    ... IE has a history of issues with the cache related control headers. ... to the request for one reason - to force IE to make the request. ... I think at the moment it is recognising the file via extension, and not by MIME type, I can also back this up by removing MIME information from the registry and it still works. ... In the morning I am going to simply compare a working set of headers to the headers that do not work, and that should provide the answer. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Question regarding mechanize lib
    ... such as the request object. ... but I need to set the headers before the post is called... ... Added protected method Mechanize#set_headers so that subclasses ... Mechanize can now be subclassed to add any headers a user may ...
    (comp.lang.ruby)