Skip to content

Commit

Permalink
add another test to show that changing content-type via pipe is OK
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Tahler committed Feb 22, 2018
1 parent 5be607f commit 6fcc60c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/servers/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,8 @@ describe('Server: Web', () => {
data.connection.pipe('a string', {'custom-header': 'cool'})
} else if (data.params.mode === 'buffer') {
data.connection.pipe(Buffer.from('a buffer'), {'custom-header': 'still-cool'})
} else if (data.params.mode === 'contentType') {
data.connection.pipe('just some good, old-fashioned words', {'Content-Type': 'text/plain', 'custom-header': 'words'})
} else {
throw new Error('I Do not know this mode')
}
Expand Down Expand Up @@ -1250,5 +1252,13 @@ describe('Server: Web', () => {
expect(response.headers['content-length']).to.exist.and.be.equal('8')
expect(response.body).to.exist.and.be.equal('a buffer')
})

it('can pipe buffer responses with custom content types to clients', async () => {
let {headers, body} = await request.get(url + '/api/pipe?mode=contentType', {resolveWithFullResponse: true})
expect(headers['content-type']).to.equal('text/plain')
expect(headers['content-length']).to.equal('35')
expect(headers['custom-header']).to.equal('words')
expect(body).to.equal('just some good, old-fashioned words')
})
})
})

0 comments on commit 6fcc60c

Please sign in to comment.