[Pkg-javascript-commits] [node-stream-http] 182/208: use blacklist instead of whitelist for methods with bodies

Bastien Roucariès rouca at moszumanska.debian.org
Sun Aug 13 13:39:43 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-stream-http.

commit 943f5bc89dcdf44c12f75f6fefd92cf8a67b64d9
Author: John Hiesey <john at hiesey.com>
Date:   Mon Apr 3 20:21:19 2017 -0700

    use blacklist instead of whitelist for methods with bodies
    
    Instead of only permitting bodies on certain methods, only
    prohibit them when the browser would give an error (with fetch)
    or ignore them (with XHR). This allows bodies with custom
    methods and is closer to the behavior of http in node.
    
    Fixes #69
---
 lib/request.js             | 2 +-
 test/browser/body-empty.js | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/request.js b/lib/request.js
index 8bec2b5..e9eb967 100644
--- a/lib/request.js
+++ b/lib/request.js
@@ -99,7 +99,7 @@ ClientRequest.prototype._onFinish = function () {
 
 	var headersObj = self._headers
 	var body = null
-	if (opts.method === 'POST' || opts.method === 'PUT' || opts.method === 'PATCH' || opts.method === 'MERGE') {
+	if (opts.method !== 'GET' && opts.method !== 'HEAD') {
 		if (capability.blobConstructor) {
 			body = new global.Blob(self._body.map(function (buffer) {
 				return toArrayBuffer(buffer)
diff --git a/test/browser/body-empty.js b/test/browser/body-empty.js
index 1ac073d..8e99bb7 100644
--- a/test/browser/body-empty.js
+++ b/test/browser/body-empty.js
@@ -6,10 +6,10 @@ var http = require('../..')
 
 var reference = fs.readFileSync(__dirname + '/../server/static/basic.txt')
 
-test('delete empty', function (t) {
+test('get body empty', function (t) {
 	var req = http.request({
 		path: '/verifyEmpty',
-		method: 'DELETE'
+		method: 'GET'
 	}, function (res) {
 		var buffers = []
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-stream-http.git



More information about the Pkg-javascript-commits mailing list