Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
Avoid blocking on empty requests
Browse files Browse the repository at this point in the history
  • Loading branch information
fbaiodias committed Mar 3, 2016
1 parent 493f51b commit 5176fa5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ Parser.prototype._transform = function (chunk, enc, cb) {
cb()
}

Parser.prototype._flush = function (cb) {
this.dicer.end()
cb()
}

Parser.prototype.handlePart = function (part) {
part.on('header', (header) => {
const partHeader = parseHeader(header)
Expand Down
18 changes: 18 additions & 0 deletions test/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,22 @@ describe('parser', () => {
})
})
})

describe('empty', () => {
before(() => {
handler = (req, cb) => {
expect(req.headers['content-type']).to.be.a('string')
const parser = IPFSMultipart.reqParser(req)

parser.on('end', cb)
}
})

it('does not block', (done) => {
request.post({ url: `http://localhost:${PORT}` }, (err, httpResponse, body) => {
expect(err).not.to.exist
done()
})
})
})
})

0 comments on commit 5176fa5

Please sign in to comment.