Adds a Basic Authentication Authorize header with properly encoded scheme and encoded username and password to the Http headers of the request.

Immediately sends this username and password with the request, not waiting for a server challenge.

o.AddHeader(lcUsername, lcPassword)


The user name to log in on the server with Basic Auth.

The password for the server


Unlike the cUsername and cPassword properties which can also be used for Authentication, this mechanism explicitly sets the header which is sent on the immediate request. The two properties require the server to first respond with an Auth Challenge, which then causes wwHttp to resend the request with the auth data. This is more secure and also results in credentials getting cached, whereas explicit sending does not.

As a general rule, if the server supports challenging, use cUsername and cPassword especially in HTML applications. If you're calling a REST Service or other service that requires Basic Auth on every request, explicitly sending the header is the better and more efficient choice.

See also:

West Wind Web Connection | wwHttp::cUsername

© West Wind Technologies, 1996-2022 • Updated: 04/29/22
Comment or report problem with topic