Skip to content

Commit

Permalink
Merge pull request request#272 from proksoup/master
Browse files Browse the repository at this point in the history
Boundary begins with CRLF?
  • Loading branch information
mikeal committed Jul 25, 2012
2 parents 5eb4c0a + 0a8a5ab commit daaad88
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions main.js
Expand Up @@ -661,6 +661,10 @@ Request.prototype.multipart = function (multipart) {

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

if (self.preambleCRLF) {
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.')
Expand Down
17 changes: 17 additions & 0 deletions tests/test-body.js
Expand Up @@ -66,6 +66,23 @@ var tests =
, {'body': 'Oh hi.'}
]
}
, testPutMultipartPreambleCRLF :
{ resp: server.createPostValidator(
'\r\n--__BOUNDARY__\r\n' +
'content-type: text/html\r\n' +
'\r\n' +
'<html><body>Oh hi.</body></html>' +
'\r\n--__BOUNDARY__\r\n\r\n' +
'Oh hi.' +
'\r\n--__BOUNDARY__--'
)
, method: "PUT"
, preambleCRLF: true
, multipart:
[ {'content-type': 'text/html', 'body': '<html><body>Oh hi.</body></html>'}
, {'body': 'Oh hi.'}
]
}
}

s.listen(s.port, function () {
Expand Down

0 comments on commit daaad88

Please sign in to comment.