Skip to content

Commit

Permalink
refactor: use http2.constants instead of hard-coded strings in http2 …
Browse files Browse the repository at this point in the history
…test
  • Loading branch information
lamweili committed Aug 2, 2022
1 parent c03efbe commit 6856f32
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/compression.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,16 +318,18 @@ describe('compression()', function () {
describeHttp2('http2', function () {
it('should work with http2 server', function (done) {
var server = createHttp2Server({ threshold: 0 }, function (req, res) {
res.setHeader('Content-Type', 'text/plain')
res.setHeader(http2.constants.HTTP2_HEADER_CONTENT_TYPE, 'text/plain')
res.end('hello, world')
})
server.on('listening', function () {
var client = createHttp2Client(server.address().port)
var request = client.request({
'Accept-Encoding': 'gzip'
[http2.constants.HTTP2_HEADER_ACCEPT_ENCODING]: 'gzip'
})
request.on('response', function (headers) {
assert.strictEqual(headers['content-encoding'], 'gzip')
assert.strictEqual(headers[http2.constants.HTTP2_HEADER_STATUS], 200)
assert.strictEqual(headers[http2.constants.HTTP2_HEADER_CONTENT_TYPE], 'text/plain')
assert.strictEqual(headers[http2.constants.HTTP2_HEADER_CONTENT_ENCODING], 'gzip')
})
var chunks = [];
request.on('data', function (chunk) {
Expand Down

0 comments on commit 6856f32

Please sign in to comment.