elasticsearch/elasticsearch-net — pull request #1035 by gmarz (2014-11-03 22:28:56+00:00)
Title: Improve API around basic authorization

This PR makes some improvements to how basic authorization is handled on the client.

Previously, basic authorization credentials needed to be specified on the URI:

var node = new Uri("http://user:password@localhost:9200");
var settings = new ConnectionSettings(node);

The above approach is still valid, however the following is now possible (and preferrred):

var node = new Uri("http://localhost:9200");
var settings = new ConnectionSettings(node)
.SetBasicAuthorization("user", "password");

Credentials can also be specified at the request level:

var response = client.RootNodeInfo(r => r
.RequestConfiguration(rc => rc
.BasicAuthorization("user", "password")
)
);

When determining what credentials to use, the client takes the following precedence (highest to lowest):

* Request level
* Connection settings level
* URI