diff --git a/README.md b/README.md index 23a7fac..f5f30f6 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/http-digest-client.js b/http-digest-client.js index 12d0d16..c03b76e 100644 --- a/http-digest-client.js +++ b/http-digest-client.js @@ -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(); }; // @@ -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(); }; // diff --git a/package.json b/package.json index 553fa33..f01c7aa 100644 --- a/package.json +++ b/package.json @@ -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 ", "contributors": [ - { - "name": "Paul Gration", - "email": "pmgration@gmail.com" - } - ] + "Paul Gration ", + "Evgenii Kozhanov " + ], + "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" + } } -