1 | 'use strict'
|
2 |
|
3 | const t = require('tap')
|
4 | const test = t.test
|
5 | const Fastify = require('../..')
|
6 | const h2url = require('h2url')
|
7 | const msg = { hello: 'world' }
|
8 |
|
9 | var fastify
|
10 | try {
|
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 |
|
19 | fastify.all('/', function (req, reply) {
|
20 | reply.code(200).send(msg)
|
21 | })
|
22 |
|
23 | fastify.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 | })
|