Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,25 @@ 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! :)
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

Expand Down
16 changes: 12 additions & 4 deletions http-digest-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ var HTTPDigest = function () {
//
HTTPDigest.prototype.request = function (options, callback) {
var self = this;
http.request(options, function (res) {
var post_req = http.request(options, function (res) {
self._handleResponse(options, res, callback);
}).end();
});
if (options.hasOwnProperty("data")) {
post_req.write(options["data"]);
}
post_req.end();
};

//
Expand Down Expand Up @@ -87,9 +91,13 @@ var HTTPDigest = function () {
headers.Authorization = this._compileParams(authParams);
options.headers = headers;

http.request(options, function (res) {
var post_req = http.request(options, function (res) {
callback(res);
}).end();
});
if (options.hasOwnProperty("data")) {
post_req.write(options["data"]);
}
post_req.end();
};

//
Expand Down
27 changes: 17 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
{
"name": "http-digest-client",
"version": "0.0.3",
"description": "Perform request agains digest authenticated servers.",
"name": "http-digest-client-with-post",
"version": "0.0.4",
"description": "Perform request agains digest authenticated servers with post (fork from https://github.com/simme/node-http-digest-client)",
"main": "http-digest-client.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/simme/node-http-digest-client"
"url": "git+https://github.com/vinger4/node-http-digest-client.git"
},
"author": "Simon Ljungberg <[email protected]>",
"contributors": [
{
"name": "Paul Gration",
"email": "[email protected]"
}
]
"Paul Gration <[email protected]>",
"Evgenii Kozhanov <[email protected]>"
],
"bugs": {
"url": "https://github.com/vinger4/node-http-digest-client/issues"
},
"homepage": "https://github.com/vinger4/node-http-digest-client#readme",
"license": "ISC",
"dependencies": {
"crypto": "0.0.3",
"http": "0.0.0",
"https": "1.0.0"
}
}