Closed pkoretic closed 8 years ago
This can already be done using for example the basic-auth-header
module:
var bhttp = require("bhttp");
var basicAuthHeader = require("basic-auth-header");
bhttp.get("http://example.com/", {
headers: {
Authorization: basicAuthHeader("username", "password")
}
});
Since basic authentication is just a header like any other, there's not really any value in adding it to bhttp
itself - it would increase complexity quite a bit for no real end-user gain, as it's already trivial to add a header anyway. It would also invite requests for many other authentication schemes being added, which makes the complexity issue worse.
I'm not sure I see your point that it "doesn't scale well" - what relation is there between authentication headers and scalability?
I'm using it like that, just without basicAuthHeader function, it seems more complicated than just providing auth object but I get your point scaling was just a reference that manually inserting http://username:auth@uri or adding autorization header is minor PITA, you need some wrappers, so out of the box is not that friendly if you have more than one url to write
Sure, but that's unrelated to scalability. I understand that it's a bit more work, but:
bhttp.session
and specifying the Authorization
header there, so that it will be set by default for every request in that session, and@joepie91 That sounds great, maybe writing this (http basic auth example) in README would be good idea for future reference
it would be nice to have basic auth support same as
request
modulemanually creating them as part of uri or header doesn't really scale well