RE: [PHP] fsockopen with apache auth
| From: | Cristian Draghici | Date: | Fri, 08 Sep 2000 14:53:37 +0000 |
| Subject: | RE: [PHP] fsockopen with apache auth | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-15890@lists.php.net to get a copy of this message | ||
>Being as the Host header begins HTTP/1.1 does that mean I need
>to make a
>different type of request? Could the host be refusing a
>http1.0 "BASIC"
>request and want a different type?
You should not use the <HOST> header when using HTTP/1.0 access. Also
servers implementing HTTP/1.1 should work just as well with HTTP/1.0
clients.
Does accessing the page work from IE or Netscape?
If it does, is your PHP script running on the same machine? Cause if
not, the PHP machine could be denied access to the realm in question.
(by ip or name or whatever)
Again, this works fine for me:
------------
function GetFromHost($host,$path)
{
$fp = fsockopen($host,80); /*don't know what happens on 911, but i
guess it should work*/
set_socket_blocking($fp, true);
fputs($fp,"GET $path HTTP/1.0\r\nAuthorization: Basic
".base64_encode("myuser:mypasswd")."\r\n\r\n");
while(!feof($fp)){
echo fgets($fp,1024);
}
fclose($fp);
}
echo nl2br(GetFromHost("mywebhost", "/mydir/myscript.php"));
------------
Check you setup, access rights, etc, there's nothing wrong with the
script.
cristi