0.0.4 • Published 8 years ago

http-digest-client-with-post v0.0.4

Weekly downloads
4
License
ISC
Repository
github
Last release
8 years ago

HTTP Digest Client

Hacked together snippet for talking to HTTP servers that employ digest authentication.

Disclaimer

Only tested against one server and spec is not followed fully. It works for me and for what I am doing.

Usage

var digest = require('http-digest-client')('username', 'password');
digest.request({
  host: 'hostname.com',
  path: '/path.json',
  port: 80,
  method: 'GET',
  headers: { "User-Agent": "Simon Ljungberg" } // Set any headers you want
}, function (res) {
  res.on('data', function (data) {
    console.log(data.toString());
  });
  res.on('error', function (err) {
    console.log('oh noes');
  });
});

The digest client will make one reques to the server, authentication response is calculated and then the request is made again. Hopefully you will then be authorized.

Writing to req

It's POST if options have property data (and it's property include post-data). Example of usage:

var digest = require('http-digest-client')('username', 'password');
digest.request({
  host: 'hostname.com',
  path: '/path.json',
  port: 80,
  method: 'POST',
  data: myPostData,
  headers: { "User-Agent": "Simon Ljungberg" } // Set any headers you want
}, function (res) {
  res.on('data', function (data) {
    console.log(data.toString());
  });
  res.on('error', function (err) {
    console.log('oh noes');
  });
});

License

See LICENSE.

0.0.4

8 years ago

0.0.3

8 years ago