diff --git a/package.json b/package.json index dd9b9dc6c..3c2e23b13 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "version": "1.16.5", - "name": "httpsnippet", + "version": "1.16.7", + "name": "@koumoul/httpsnippet", "description": "HTTP Request snippet generator for *most* languages", "author": "Ahmad Nassri (https://www.mashape.com/)", "homepage": "https://github.com/Mashape/httpsnippet", @@ -81,7 +81,7 @@ "commander": "^2.9.0", "debug": "^2.2.0", "event-stream": "^3.3.2", - "form-data": "^1.0.0-rc3", + "form-data": "^2.3.3", "fs-readfile-promise": "^2.0.1", "fs-writefile-promise": "^1.0.3", "har-validator": "^5.0.0", diff --git a/src/index.js b/src/index.js index 0c6cf1bd6..669a20133 100644 --- a/src/index.js +++ b/src/index.js @@ -103,7 +103,7 @@ HTTPSnippet.prototype.prepare = function (request) { request.postData.mimeType = 'multipart/form-data' if (request.postData.params) { - var form = new MultiPartForm() + /*var form = new MultiPartForm() // easter egg form._boundary = '---011000010111000001101001' @@ -121,6 +121,18 @@ HTTPSnippet.prototype.prepare = function (request) { request.postData.boundary = form.getBoundary() request.headersObj['content-type'] = 'multipart/form-data; boundary=' + form.getBoundary() + */ + + // simpler management of multipart/form-data + // writing the real content of the files is probably not a good idea anyway + if (!request.postData.params) { + request.postData.text = '' + } else { + request.postData.paramsObj = request.postData.params.reduce(reducer, {}) + + // always overwrite + request.postData.text = qs.stringify(request.postData.paramsObj) + } } break