commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Geisser <>
Subject Re: HTTPClient
Date Tue, 29 Apr 2003 21:49:59 GMT
Hi, wrote:
> Hi everybody!
> I'm both new to http communication, http client and I'm trying to send
> files with
> authentication. However, when sending the request, the request header does
> not contain
> any authorization header. Shouldn't it? How does it work?

Have a look at the authentication guide:

The short answer is to use:
   setSystemProperty(Authenticator.PREEMPTIVE_PROPERTY, "true");

If you want to understand why/how this works you must know
that "usually" authentication is done on the "second try".
The first request is sent without authentication headers and gets
a "406 Unauthorized" response which includes a "authentication" header.
Then with the second request the first request is repeated but with
additional authentication information.

For more details read the "HTTP 1.1 Authentication Specification" RFC.

Setting the above property will force HTTPClient to send 
username/password with every request.

Ciao, Olli


View raw message