From 44245551c52466b559f9171957ef096c0f728794 Mon Sep 17 00:00:00 2001 From: vinger4 Date: Sun, 28 Feb 2016 12:04:13 +0300 Subject: [PATCH 1/7] quickfix for POST --- http-digest-client.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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(); }; // From 87dd5a7dfd50c7c19db3aeb0d4f74ea8ec11d649 Mon Sep 17 00:00:00 2001 From: Evgenii Kozhanov Date: Fri, 4 Mar 2016 18:30:15 +0300 Subject: [PATCH 2/7] update Writing to req --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 23a7fac..63fa805 100644 --- a/README.md +++ b/README.md @@ -32,8 +32,7 @@ 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) # License From 5a4715535af04440bbe67494f06c51c381f88e64 Mon Sep 17 00:00:00 2001 From: vinger4 Date: Sun, 6 Mar 2016 11:39:54 +0300 Subject: [PATCH 3/7] quickfix description --- package.json | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 553fa33..069a3c0 100644 --- a/package.json +++ b/package.json @@ -1,20 +1,24 @@ { - "name": "http-digest-client", + "name": "http-digest-client-with-post", "version": "0.0.3", - "description": "Perform request agains digest authenticated servers.", + "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": "https://github.com/vinger4/node-http-digest-client" }, "author": "Simon Ljungberg ", "contributors": [ { "name": "Paul Gration", "email": "pmgration@gmail.com" + }, + { + "name": "Evgenii Kozhanov", + "email": "evgenii.kozhanov@gmail.com" } ] } From 294cb67323404473335313701dc5e1bf906a5c5d Mon Sep 17 00:00:00 2001 From: vinger4 Date: Sun, 6 Mar 2016 11:51:45 +0300 Subject: [PATCH 4/7] update package.json --- package.json | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 069a3c0..e8fd440 100644 --- a/package.json +++ b/package.json @@ -8,18 +8,21 @@ }, "repository": { "type": "git", - "url": "https://github.com/vinger4/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" - }, - { - "name": "Evgenii Kozhanov", - "email": "evgenii.kozhanov@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" + } } - From 22c76d5646f3302a54e4dd6a39b696a5e0d26020 Mon Sep 17 00:00:00 2001 From: Evgenii Kozhanov Date: Sun, 6 Mar 2016 11:57:18 +0300 Subject: [PATCH 5/7] Update README.md --- README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 63fa805..f5f30f6 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,25 @@ be authorized. ## Writing to `req` -It's POST if `options` have property `data` (and it's property include post-data) +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 From 59644780dc8cb6cdd8384a095b7262d36a5e8fe5 Mon Sep 17 00:00:00 2001 From: vinger4 Date: Sun, 6 Mar 2016 11:59:40 +0300 Subject: [PATCH 6/7] update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e8fd440..c9cb058 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "homepage": "https://github.com/vinger4/node-http-digest-client#readme", "license": "ISC", "dependencies": { - "crypto": "0.0.3", + "crypto": "0.0.4", "http": "0.0.0", "https": "1.0.0" } From fd7393e3ce70813a30166088c79be7dbcdb0bba1 Mon Sep 17 00:00:00 2001 From: vinger4 Date: Sun, 6 Mar 2016 12:00:09 +0300 Subject: [PATCH 7/7] update package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c9cb058..f01c7aa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "http-digest-client-with-post", - "version": "0.0.3", + "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": { @@ -21,7 +21,7 @@ "homepage": "https://github.com/vinger4/node-http-digest-client#readme", "license": "ISC", "dependencies": { - "crypto": "0.0.4", + "crypto": "0.0.3", "http": "0.0.0", "https": "1.0.0" }