473,394 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Basic Authentication question.

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:

<?php
$fp = fsockopen("www.mydomain.com",80);
fputs($fp,"GET /downloads HTTP/1.0\r\n");
fputs($fp,"Host: www.mydomain.com\r\n");
fputs($fp,"Authorization: Basic " . base64_encode("user:pass") . "\r\n\
\n");
fpassthru($fp);
?>

This works almost fine.
I say almost because I can't stop showing the server response string from my
page:
"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.
Jul 17 '05 #1
2 1804
Nuno Paquete <nm*@ispgaya.pt> wrote:
$fp = fsockopen("www.mydomain.com",80);
fputs($fp,"GET /downloads HTTP/1.0\r\n");
fputs($fp,"Host: www.mydomain.com\r\n");
fputs($fp,?uthorization: Basic " . base64_encode(?ser:pass") . "\r\n\
\n");
fpassthru($fp);
?>

This works almost fine.
I say almost because I can't stop showing the server response string from my
page:
"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?


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);

while(!feof($fp))
{
echo fgets($fp);
}

(untested)

--

Daniel Tryba

Jul 17 '05 #2
Daniel Tryba wrote:
Nuno Paquete <nm*@ispgaya.pt> wrote:
$fp = fsockopen("www.mydomain.com",80);
fputs($fp,"GET /downloads HTTP/1.0\r\n");
fputs($fp,"Host: www.mydomain.com\r\n");
fputs($fp,?uthorization: Basic " . base64_encode(?ser:pass") . "\r\n\
\n");
fpassthru($fp);
?>

This works almost fine.
I say almost because I can't stop showing the server response string from
my page:
"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?


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);

while(!feof($fp))
{
echo fgets($fp);
}

(untested)

Thanks. That's it.
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Michael Foord | last post by:
#!/usr/bin/python -u # 15-09-04 # v1.0.0 # auth_example.py # A simple script manually demonstrating basic authentication. # Copyright Michael Foord # Free to use, modify and relicense. #...
1
by: mark wade | last post by:
Thanks for any help in advance. I am new at HTML. I have two programs to use to develop a website (personal) Frontpage and HTML-Kit. My question is, if I use Frontpage, I am limited to using IIS...
3
by: Yodai | last post by:
Hi all... I have this project on an embbeded system where I've programmed a very simple dynamic web-server on C, which serves 1 connection at a time. I need to implement a basic authentication...
4
by: Dave | last post by:
Hi, Is there anyway to mimic forms authentication's loginUrl and RedirectFromLoginPage functionality using Windows authentication? We are developing intranet sites using basic authentication...
3
by: sefe dery | last post by:
hi ng, i try to create a asp.net 1.0 website on windows server 2003(Servername: ServerX) with iis 6.0. PROBLEM: The user should login with his windows credentials in basic.aspx and...
13
by: Pete | last post by:
I'm cross posting from mscom.webservices.general as I have received no answer there: There has been a number of recent posts requesting how to satisfactorily enable BASIC authorization at the...
3
by: Martin | last post by:
How does one set up basic authentication on an HttpListener? I know I need to set the HttpListener.AuthenticationSchemes to AuthenticationSchemes.Basic but then I'm unsure how and against what...
0
by: =?Utf-8?B?S29uc3RhbnRpbg==?= | last post by:
I am currently working on the application that need to simulate basic authentication programmatically using user's credentials that are known. Basically, the need is for a single sign on with a...
8
by: =?Utf-8?B?TFc=?= | last post by:
Hello! I am just learning about forms authentication so please excuse this basic question. I am using .NET 1.1 and C#. I have created my web.config file and my login.aspx and the associated cs...
0
by: =?Utf-8?B?UHZkYl9CQQ==?= | last post by:
Hi all, I have a problem with accessing a webservice from Access2000 (=VBA). I hope I can place this question in this group. If no, please give me an better place it. So, i'm try to connect...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.