Skip to content

Commit

Permalink
Updating with corresponding tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek Bredensteiner committed Jul 6, 2012
1 parent 3daebaf commit dba2ebf
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -663,11 +663,12 @@ Request.prototype.multipart = function (multipart) {

if (!multipart.forEach) throw new Error('Argument error, options.multipart.')

self.body.push(new Buffer('\r\n'))
multipart.forEach(function (part) {
var body = part.body
if(body == null) throw Error('Body attribute missing in multipart.')
delete part.body
var preamble = '\r\n' + '--' + self.boundary + '\r\n'
var preamble = '--' + self.boundary + '\r\n'
Object.keys(part).forEach(function (key) {
preamble += key + ': ' + part[key] + '\r\n'
})
Expand Down
2 changes: 1 addition & 1 deletion tests/test-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var tests =
}
, testPutMultipart :
{ resp: server.createPostValidator(
'--__BOUNDARY__\r\n' +
'\r\n--__BOUNDARY__\r\n' +
'content-type: text/html\r\n' +
'\r\n' +
'<html><body>Oh hi.</body></html>' +
Expand Down
2 changes: 1 addition & 1 deletion tests/test-https-strict.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var tests =
}
, testPutMultipart :
{ resp: server.createPostValidator(
'--__BOUNDARY__\r\n' +
'\r\n--__BOUNDARY__\r\n' +
'content-type: text/html\r\n' +
'\r\n' +
'<html><body>Oh hi.</body></html>' +
Expand Down
2 changes: 1 addition & 1 deletion tests/test-https.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var tests =
}
, testPutMultipart :
{ resp: server.createPostValidator(
'--__BOUNDARY__\r\n' +
'\r\n--__BOUNDARY__\r\n' +
'content-type: text/html\r\n' +
'\r\n' +
'<html><body>Oh hi.</body></html>' +
Expand Down

0 comments on commit dba2ebf

Please sign in to comment.