From 76a1b867f11f5f9fdd83563ab61e8bd3817ef403 Mon Sep 17 00:00:00 2001 From: Vadim Efimov Date: Wed, 25 Jan 2017 13:10:47 +0300 Subject: [PATCH] form support for PUT and POST Two fixes here: 1. Method can be manually set via method: 'post', so we need the method check to be not case sensitive 2. Sometimes form data is required for PUT requests --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 1a77c6f..2e114d5 100644 --- a/index.js +++ b/index.js @@ -124,7 +124,7 @@ function request(options, callback) { if(options.form){ if(typeof options.form == 'string') throw('form name unsupported'); - if(options.method === 'POST'){ + if(options.method.toLowerCase() === 'post' || options.method.toLowerCase() === 'put'){ var encoding = (options.encoding || 'application/x-www-form-urlencoded').toLowerCase(); options.headers['content-type'] = encoding; switch(encoding){