W3C home > Mailing lists > Public > www-lib@w3.org > January to March 2001

Re: How to set the authorization header ?

From: Jeff Adams <jeffa@coursewave.com>
Date: Fri, 09 Mar 2001 11:13:28 -0600
Message-ID: <3AA90F38.67031CFD@coursewave.com>
To: Timo.Ross@ic3s.de
CC: www-lib@w3.org
Timo.Ross@ic3s.de wrote:
> 
> Hi all!
> 
> I want to set the authorization header with username / password, but I do
> not realy know how! Can any body help ???
> 
> Thanks in advance ...
> Timo!

Hi Timo,

One low-level way of setting authentication is by setting
the credentials on an HTRequest yourself doing things like:

HTRequest_addCredentials(request, "Authorization", "Basic ...");

where you might send a Basic credential with the username and password
Base64 
encoded... 

but perhaps the more natural way is for you to simply 
override the username and password callback so that you simply
supply the username and password and let libwww handle the proper
Basic or Digest encoding of the response from any server-side
Authentication
challenge.

You can setup your own callback for username and password requests
using:

    HTAlert_add(MyPrompt, HT_A_PROMPT);
    HTAlert_add(MyPromptPassword, HT_A_SECRET);
    HTAlert_add(MyPromptUsernameAndPassword, HT_A_USER_PW);

where the My... functions would handle your supplying of any prompts.
By default you may notice a simple stdin interface is supplied on Unix.

Look at the code in HTDialog.c where the default implementations
for the prompt callback functions exist. In your libwww client you can
setup
your own callback functions and then handle username and password
prompts with a GUI
dialog for instance...

Hope this helps
Jeff
Received on Friday, 9 March 2001 12:10:06 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:38 GMT