Skip to content

Commit a94ba2c

Browse files
committed
Revert "Fix browserify support (with webpack)."
This reverts commit a968e69.
1 parent 493c1f7 commit a94ba2c

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@
8282
"chalk": "^1.1.1",
8383
"commander": "^2.9.0",
8484
"debug": "^2.2.0",
85+
"event-stream": "^3.3.2",
86+
"form-data": "^1.0.0-rc3",
8587
"fs-readfile-promise": "^2.0.1",
8688
"fs-writefile-promise": "^1.0.3",
8789
"har-validator": "^2.0.2",

src/index.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
'use strict'
22

33
var debug = require('debug')('httpsnippet')
4+
var es = require('event-stream')
5+
var MultiPartForm = require('form-data')
46
var qs = require('querystring')
57
var reducer = require('./helpers/reducer')
68
var targets = require('./targets')
@@ -101,17 +103,24 @@ HTTPSnippet.prototype.prepare = function (request) {
101103
request.postData.mimeType = 'multipart/form-data'
102104

103105
if (request.postData.params) {
104-
var form = new FormData()
106+
var form = new MultiPartForm()
105107

106108
// easter egg
107109
form._boundary = '---011000010111000001101001'
108110

109111
request.postData.params.forEach(function (param) {
110-
form.append(param.name, param.value || '')
112+
form.append(param.name, param.value || '', {
113+
filename: param.fileName || null,
114+
contentType: param.contentType || null
115+
})
111116
})
112117

113-
request.postData.boundary = form._boundary
114-
request.headersObj['content-type'] = 'multipart/form-data; boundary=' + form._boundary
118+
form.pipe(es.map(function (data, cb) {
119+
request.postData.text += data
120+
}))
121+
122+
request.postData.boundary = form.getBoundary()
123+
request.headersObj['content-type'] = 'multipart/form-data; boundary=' + form.getBoundary()
115124
}
116125
break
117126

0 commit comments

Comments
 (0)