UNPKG

690 BJavaScriptView Raw
1'use strict'
2
3const t = require('tap')
4const test = t.test
5const Fastify = require('../..')
6const h2url = require('h2url')
7const msg = { hello: 'world' }
8
9var fastify
10try {
11 fastify = Fastify({
12 http2: true
13 })
14 t.pass('http2 successfully loaded')
15} catch (e) {
16 t.fail('http2 loading failed', e)
17}
18
19fastify.all('/', function (req, reply) {
20 reply.code(200).send(msg)
21})
22
23fastify.listen(0, err => {
24 t.error(err)
25 fastify.server.unref()
26
27 test('http HEAD request', async (t) => {
28 t.plan(1)
29
30 const url = `http://localhost:${fastify.server.address().port}`
31 const res = await h2url.concat({ url, method: 'HEAD' })
32
33 t.strictEqual(res.headers[':status'], 200)
34 })
35})