Skip to content
Make HTTP requests to servers that employ digest authentication.
JavaScript
Find file
Latest commit baab015 Feb 18, 2015 @simme Merge pull request #8 from dayuoba/patch-1
Update README.md
Failed to load latest commit information.
LICENSE Add license Nov 22, 2012
README.md Update README.md Feb 9, 2015
http-digest-client.js Add option for HTTPS. Jan 20, 2014
package.json Fix typo in previous commit. Jan 21, 2014

README.md

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

I haven't yet figured out a way to write data to the final req object. Mainly because I haven't really needed it. Feel free to suggest solutions! :)

License

See LICENSE.

Something went wrong with that request. Please try again.