Re: [PHP] fsockopen and HTTP Authorization

2002-02-28 Thread Mika Tuupola

On Thu, 28 Feb 2002, Bas Jobsen wrote:

> I try to do a HTTP Authorization with a fsockopen, but it doesn't seem to 
> work. Who can help?
> $user and $passwd are set well, my code:

I think you can spy from PEAR HTTP_Request class how it
can be done:

http://chora.php.net/cvs.php/pear/HTTP_Request

-- 
Mika Tuupola  http://www.appelsiini.net/~tuupola/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] fsockopen and HTTP Authorization

2002-02-27 Thread Bogdan Stancescu

You should have only one \r\n pair after the HTTP request AFAIK - only 
need two when the header ends.

Bogdan

Bas Jobsen wrote:

>Hello,
>
>I try to do a HTTP Authorization with a fsockopen, but it doesn't seem to 
>work. Who can help?
>$user and $passwd are set well, my code:
>--
>$auth=base64_encode($user.":".$passwd);
>$header="GET /pa2/ HTTP/1.0\r\n\r\n";
>$header.="Accept: text/html\r\n";
>$header.="Authorization: Basic $auth\r\n\r\n";
>
>$fp = fsockopen ("localhost", 80, $errno, $errstr, 30);
>if (!$fp) echo "$errstr ($errno)\n";
>else
>{
>fputs ($fp,  $header);
>while (!feof($fp)) echo fgets ($fp,128);
>}
>fclose ($fp);
>--
>
>Thanks,
>
>Bas
>




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] fsockopen and HTTP Authorization

2002-02-27 Thread Bas Jobsen

Hello,

I try to do a HTTP Authorization with a fsockopen, but it doesn't seem to 
work. Who can help?
$user and $passwd are set well, my code:
--
$auth=base64_encode($user.":".$passwd);
$header="GET /pa2/ HTTP/1.0\r\n\r\n";
$header.="Accept: text/html\r\n";
$header.="Authorization: Basic $auth\r\n\r\n";

$fp = fsockopen ("localhost", 80, $errno, $errstr, 30);
if (!$fp) echo "$errstr ($errno)\n";
else
{
fputs ($fp,  $header);
while (!feof($fp)) echo fgets ($fp,128);
}
fclose ($fp);
--

Thanks,

Bas

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php