Skip to content

Commit

Permalink
added a test case for setting content-length header value to NaN when…
Browse files Browse the repository at this point in the history
… using chunked HTTP response in form data.
  • Loading branch information
jongyoonlee committed Dec 11, 2015
1 parent f1b59e1 commit 53f5d13
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion tests/test-form-data-error.js
Expand Up @@ -27,8 +27,46 @@ tape('re-emit formData errors', function(t) {
}).form().append('field', ['value1', 'value2'])
})

tape('omit content-length header if the value is set to NaN', function(t) {

// returns chunked HTTP response which is streamed to the 2nd HTTP request in the form data
s.on('/chunky', server.createChunkResponse(
['some string',
'some other string'
]))

// accepts form data request
s.on('/stream', function(req, resp) {
req.on('data', function(chunk) {
// consume the request body
})
req.on('end', function() {
resp.writeHead(200)
resp.end()
})
})

var sendStreamRequest = function(stream) {
request.post({
uri: s.url + '/stream',
formData: {
param: stream
}
}, function(err, res) {
t.error(err, 'request failed')
t.end()
})
}

request.get({
uri: s.url + '/chunky',
}).on('response', function(res) {
sendStreamRequest(res)
})
})

tape('cleanup', function(t) {
s.close(function() {
t.end()
})
})
})

0 comments on commit 53f5d13

Please sign in to comment.