SamDecrock / node-http-ntlm

Node.js module to authenticate using HTTP NTLM
MIT License
192 stars 89 forks source link

Allow passing in an http agent. #66

Closed lucyluu22 closed 1 year ago

lucyluu22 commented 7 years ago

Correct me if I'm wrong, but wouldn't re-using a http agent instead of creating a new one every request mean you'd only need to do do the handshake once on the same server (since the connection would be persisted)?

May also help issue #5

SamDecrock commented 1 year ago

The keepaliveAgent is only created once and then re-used for all messages.

SamDecrock commented 1 year ago

Ah, you mean when you (as and end-user of my module) create multiple connections to the server... I get it. I'll look into it when I find the time.

SamDecrock commented 1 year ago

Added the option in version 1.8.9

Eg

var httpntlm = require('httpntlm');
var http = require('http');

var myKeepaliveAgent = new http.Agent({keepAlive: true});

httpntlm.get({
  url: "http://localhost:3000",
  username: 'm$',
  password: 'stinks',
  workstation: 'choose.something',
  domain: 'somedomain',
  agent: myKeepaliveAgent
}, function (err, res){
  if(err) return console.log(err);

  console.log(res.headers);
  console.log(res.body);
});