Permalink
Browse files

Okay, trying it as an optional parameter, with a new test in test-bod…

…y.js to verify
  • Loading branch information...
Derek Bredensteiner
Derek Bredensteiner committed Jul 6, 2012
1 parent 396531d commit 54226a38816b4169e0a7a5d8b1a7feba78235fec
Showing with 23 additions and 3 deletions.
  1. +4 −1 main.js
  2. +17 −0 tests/test-body.js
  3. +1 −1 tests/test-https-strict.js
  4. +1 −1 tests/test-https.js
View
@@ -661,7 +661,10 @@ Request.prototype.multipart = function (multipart) {
if (!multipart.forEach) throw new Error('Argument error, options.multipart.')
- self.body.push(new Buffer('\r\n'))
+ 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.')
View
@@ -51,6 +51,22 @@ var tests =
, json: {foo: 'bar'}
}
, testPutMultipart :
+ { resp: server.createPostValidator(
+ '--__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"
+ , multipart:
+ [ {'content-type': 'text/html', 'body': '<html><body>Oh hi.</body></html>'}
+ , {'body': 'Oh hi.'}
+ ]
+ }
+ , testPutMultipartPreambleCRLF :
{ resp: server.createPostValidator(
'\r\n--__BOUNDARY__\r\n' +
'content-type: text/html\r\n' +
@@ -61,6 +77,7 @@ var tests =
'\r\n--__BOUNDARY__--'
)
, method: "PUT"
+ , preambleCRLF: true
, multipart:
[ {'content-type': 'text/html', 'body': '<html><body>Oh hi.</body></html>'}
, {'body': 'Oh hi.'}
@@ -52,7 +52,7 @@ var tests =
}
, testPutMultipart :
{ resp: server.createPostValidator(
- '\r\n--__BOUNDARY__\r\n' +
+ '--__BOUNDARY__\r\n' +
'content-type: text/html\r\n' +
'\r\n' +
'<html><body>Oh hi.</body></html>' +
View
@@ -44,7 +44,7 @@ var tests =
}
, testPutMultipart :
{ resp: server.createPostValidator(
- '\r\n--__BOUNDARY__\r\n' +
+ '--__BOUNDARY__\r\n' +
'content-type: text/html\r\n' +
'\r\n' +
'<html><body>Oh hi.</body></html>' +

0 comments on commit 54226a3

Please sign in to comment.