Basic Authentication question.

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi group.
I've got Basic Authentication working almost fine, so I need to resolve a
little problem.
I've got this code in my php scrip:

$fp = fsockopen("",80);
fputs($fp,"GET /downloads HTTP/1.0\r\n");
fputs($fp,"Authorization: Basic " . base64_encode("user:pass") . "\r\n\

This works almost fine.
I say almost because I can't stop showing the server response string from my
"HTTP/1.1 200 OK Date: Fri, 23 Jul 2004 17:37:40 GMT Server: Apache/1.3.31
(Unix) PHP/4.3.6 Connection: close Content-Type: text/html"

How can I stop showing this text from in my page?

Best regards,

Nuno Paquete.

Re: Basic Authentication question.

Quoted text here. Click to load it

Don't use fpassthru... use fgets. Headers are the lines till the first
"empty" line, munch them and output the rest.

while(!feof($fp) && strlen(rtrim(fgets($fp)))!==0);

   echo fgets($fp);



  Daniel Tryba

Re: Basic Authentication question.

Daniel Tryba wrote:

Quoted text here. Click to load it

Thanks. That's it.

Site Timeline