@fastify/reply-from 12.0.0 → 12.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/dependabot.yml +1 -1
- package/.github/workflows/ci.yml +0 -1
- package/README.md +16 -16
- package/eslint.config.js +6 -0
- package/examples/example.js +2 -2
- package/index.js +6 -8
- package/lib/request.js +4 -4
- package/package.json +37 -10
- package/test/async-route-handler.test.js +1 -1
- package/test/base-get.test.js +1 -1
- package/test/base-path.test.js +2 -2
- package/test/base-querystring.test.js +1 -1
- package/test/core-with-path-in-base.test.js +1 -1
- package/test/custom-undici-instance.test.js +2 -2
- package/test/disable-request-logging.test.js +3 -3
- package/test/fastify-multipart-incompatibility.test.js +2 -2
- package/test/fix-GHSA-v2v2-hph8-q5xp.test.js +52 -36
- package/test/full-delete-http2.test.js +2 -2
- package/test/full-get-test.test.js +1 -1
- package/test/full-https-get.test.js +1 -1
- package/test/full-post-extended-content-type.test.js +1 -1
- package/test/full-post-http2.test.js +1 -1
- package/test/full-post-stream-core.test.js +3 -3
- package/test/full-post-stream.test.js +3 -3
- package/test/full-post.test.js +2 -2
- package/test/full-querystring-rewrite-option-complex.test.js +1 -1
- package/test/full-querystring-rewrite-option-function-request.test.js +3 -3
- package/test/full-querystring-rewrite-option-function.test.js +1 -1
- package/test/full-querystring-rewrite-option.test.js +1 -1
- package/test/full-querystring-rewrite-string.test.js +1 -1
- package/test/full-querystring-rewrite.test.js +1 -1
- package/test/full-querystring.test.js +1 -1
- package/test/full-rewrite-body-content-type.test.js +10 -7
- package/test/full-rewrite-body-http.test.js +2 -2
- package/test/full-rewrite-body-to-empty-string.test.js +2 -2
- package/test/full-rewrite-body-to-null.test.js +2 -2
- package/test/full-rewrite-body.test.js +2 -2
- package/test/get-upstream-http.test.js +3 -3
- package/test/get-upstream-undici.test.js +1 -1
- package/test/get-with-body.test.js +1 -1
- package/test/head-with-body.test.js +1 -7
- package/test/host-header.test.js +4 -4
- package/test/http-agents.test.js +1 -1
- package/test/http-global-agent.test.js +1 -1
- package/test/http-http2.test.js +2 -2
- package/test/http-invalid-target.test.js +1 -1
- package/test/http-retry.test.js +3 -3
- package/test/http-timeout.test.js +4 -4
- package/test/http2-http2.test.js +2 -2
- package/test/http2-https.test.js +2 -2
- package/test/http2-invalid-target.test.js +1 -1
- package/test/http2-target-crash.test.js +2 -2
- package/test/http2-target-multi-crash.test.js +1 -1
- package/test/http2-timeout-disabled.test.js +2 -2
- package/test/http2-timeout.test.js +4 -4
- package/test/https-agents.test.js +1 -1
- package/test/https-global-agent.test.js +1 -1
- package/test/method.test.js +3 -3
- package/test/modifyCoreObjects-false.test.js +1 -1
- package/test/no-body-opts-with-get.test.js +2 -2
- package/test/no-body-opts-with-head.test.js +2 -2
- package/test/no-stream-body-option.test.js +2 -2
- package/test/on-error.test.js +2 -2
- package/test/on-invalid-upstream-response.test.js +1 -1
- package/test/padded-body.test.js +2 -2
- package/test/post-formbody.test.js +1 -1
- package/test/post-plain-text.test.js +1 -1
- package/test/post-with-custom-encoded-contenttype.test.js +2 -2
- package/test/post-with-octet-stream.test.js +5 -5
- package/test/retry-on-503.test.js +4 -4
- package/test/retry-with-a-custom-handler.test.js +7 -7
- package/test/rewrite-headers-type.test.js +2 -2
- package/test/rewrite-headers.test.js +3 -3
- package/test/rewrite-request-headers-type.test.js +2 -2
- package/test/rewrite-request-headers.test.js +2 -2
- package/test/transform-body.test.js +3 -3
- package/test/undici-agent.test.js +2 -2
- package/test/undici-body.test.js +3 -3
- package/test/undici-chaining.test.js +3 -3
- package/test/undici-connect-timeout.test.js +2 -2
- package/test/undici-custom-dispatcher.test.js +2 -2
- package/test/undici-global-agent.test.js +2 -2
- package/test/undici-no-destroy.test.js +1 -1
- package/test/undici-options.test.js +2 -2
- package/test/undici-proxy-agent.test.js +47 -28
- package/test/undici-retry.test.js +3 -3
- package/test/undici-timeout-body-partial.test.js +1 -1
- package/test/undici-timeout-body.test.js +1 -1
- package/test/undici-timeout.test.js +2 -2
- package/test/undici-with-path-in-base.test.js +1 -1
- package/test/undici.test.js +1 -1
- package/test/unexpected-error.test.js +2 -2
- package/test/unix-http-undici-from.test.js +3 -3
- package/test/unix-http-undici.test.js +1 -1
- package/test/unix-http.test.js +1 -1
- package/test/unix-https-undici.test.js +1 -1
- package/test/unix-https.test.js +1 -1
- package/types/index.d.ts +10 -11
- package/types/index.test-d.ts +138 -108
|
@@ -12,7 +12,7 @@ instance.register(From)
|
|
|
12
12
|
t.plan(8)
|
|
13
13
|
t.teardown(instance.close.bind(instance))
|
|
14
14
|
|
|
15
|
-
instance.addContentTypeParser('application/octet-stream', function (
|
|
15
|
+
instance.addContentTypeParser('application/octet-stream', function (_req, payload, done) {
|
|
16
16
|
done(null, payload)
|
|
17
17
|
})
|
|
18
18
|
|
|
@@ -35,7 +35,7 @@ const target = http.createServer((req, res) => {
|
|
|
35
35
|
})
|
|
36
36
|
})
|
|
37
37
|
|
|
38
|
-
instance.post('/', (
|
|
38
|
+
instance.post('/', (_request, reply) => {
|
|
39
39
|
reply.from(`http://localhost:${target.address().port}`)
|
|
40
40
|
})
|
|
41
41
|
|
|
@@ -56,7 +56,7 @@ instance.listen({ port: 0 }, (err) => {
|
|
|
56
56
|
body: JSON.stringify({
|
|
57
57
|
hello: 'world'
|
|
58
58
|
})
|
|
59
|
-
}, (err,
|
|
59
|
+
}, (err, _res, data) => {
|
|
60
60
|
t.error(err)
|
|
61
61
|
t.same(JSON.parse(data), { something: 'else' })
|
|
62
62
|
})
|
package/test/full-post.test.js
CHANGED
|
@@ -29,7 +29,7 @@ const target = http.createServer((req, res) => {
|
|
|
29
29
|
})
|
|
30
30
|
})
|
|
31
31
|
|
|
32
|
-
instance.post('/', (
|
|
32
|
+
instance.post('/', (_request, reply) => {
|
|
33
33
|
reply.from(`http://localhost:${target.address().port}`)
|
|
34
34
|
})
|
|
35
35
|
|
|
@@ -48,7 +48,7 @@ instance.listen({ port: 0 }, (err) => {
|
|
|
48
48
|
body: {
|
|
49
49
|
hello: 'world'
|
|
50
50
|
}
|
|
51
|
-
}, (err,
|
|
51
|
+
}, (err, _res, data) => {
|
|
52
52
|
t.error(err)
|
|
53
53
|
t.same(data, { something: 'else' })
|
|
54
54
|
})
|
|
@@ -21,7 +21,7 @@ const target = http.createServer((req, res) => {
|
|
|
21
21
|
res.end('hello world')
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
-
instance.get('/hello', (
|
|
24
|
+
instance.get('/hello', (_request, reply) => {
|
|
25
25
|
reply.from(`http://localhost:${target.address().port}/world?a=b`, {
|
|
26
26
|
queryString: { b: 'c' }
|
|
27
27
|
})
|
|
@@ -9,7 +9,7 @@ const querystring = require('node:querystring')
|
|
|
9
9
|
|
|
10
10
|
const instance = Fastify()
|
|
11
11
|
|
|
12
|
-
instance.addHook('preHandler', (request,
|
|
12
|
+
instance.addHook('preHandler', (request, _reply, done) => {
|
|
13
13
|
request.addedVal = 'test'
|
|
14
14
|
done()
|
|
15
15
|
})
|
|
@@ -27,9 +27,9 @@ const target = http.createServer((req, res) => {
|
|
|
27
27
|
res.end('hello world')
|
|
28
28
|
})
|
|
29
29
|
|
|
30
|
-
instance.get('/hello', (
|
|
30
|
+
instance.get('/hello', (_request, reply) => {
|
|
31
31
|
reply.from(`http://localhost:${target.address().port}/world?a=b`, {
|
|
32
|
-
queryString (
|
|
32
|
+
queryString (_search, _reqUrl, request) {
|
|
33
33
|
return querystring.stringify({ q: request.addedVal })
|
|
34
34
|
}
|
|
35
35
|
})
|
|
@@ -22,7 +22,7 @@ const target = http.createServer((req, res) => {
|
|
|
22
22
|
res.end('hello world')
|
|
23
23
|
})
|
|
24
24
|
|
|
25
|
-
instance.get('/hello', (
|
|
25
|
+
instance.get('/hello', (_request, reply) => {
|
|
26
26
|
reply.from(`http://localhost:${target.address().port}/world?a=b`, {
|
|
27
27
|
queryString () {
|
|
28
28
|
return querystring.stringify({ b: 'c' })
|
|
@@ -21,7 +21,7 @@ const target = http.createServer((req, res) => {
|
|
|
21
21
|
res.end('hello world')
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
-
instance.get('/hello', (
|
|
24
|
+
instance.get('/hello', (_request, reply) => {
|
|
25
25
|
reply.from(`http://localhost:${target.address().port}/world`, {
|
|
26
26
|
queryString: { b: 'c' }
|
|
27
27
|
})
|
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
const t = require('tap')
|
|
4
4
|
const Fastify = require('fastify')
|
|
5
|
-
const
|
|
5
|
+
const fastifyReplyFrom = require('..')
|
|
6
6
|
const http = require('node:http')
|
|
7
7
|
const get = require('simple-get').concat
|
|
8
|
-
const msgpack = require('msgpack5')()
|
|
9
8
|
|
|
10
9
|
const instance = Fastify()
|
|
11
|
-
instance.register(
|
|
10
|
+
instance.register(fastifyReplyFrom)
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
const payload = { hello: 'world' }
|
|
13
|
+
const msgPackPayload = Buffer.from([0x81, 0xa5, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0xa5, 0x77, 0x6f, 0x72, 0x6c, 0x64])
|
|
14
|
+
|
|
15
|
+
t.plan(9)
|
|
14
16
|
t.teardown(instance.close.bind(instance))
|
|
15
17
|
|
|
16
18
|
const target = http.createServer((req, res) => {
|
|
@@ -22,7 +24,7 @@ const target = http.createServer((req, res) => {
|
|
|
22
24
|
data.push(d)
|
|
23
25
|
})
|
|
24
26
|
req.on('end', () => {
|
|
25
|
-
t.same(
|
|
27
|
+
t.same(Buffer.concat(data), msgPackPayload)
|
|
26
28
|
res.statusCode = 200
|
|
27
29
|
res.setHeader('content-type', 'application/json')
|
|
28
30
|
res.end(JSON.stringify({ something: 'else' }))
|
|
@@ -30,9 +32,10 @@ const target = http.createServer((req, res) => {
|
|
|
30
32
|
})
|
|
31
33
|
|
|
32
34
|
instance.post('/', (request, reply) => {
|
|
35
|
+
t.same(request.body, payload)
|
|
33
36
|
reply.from(`http://localhost:${target.address().port}`, {
|
|
34
37
|
contentType: 'application/msgpack',
|
|
35
|
-
body:
|
|
38
|
+
body: msgPackPayload
|
|
36
39
|
})
|
|
37
40
|
})
|
|
38
41
|
|
|
@@ -51,7 +54,7 @@ instance.listen({ port: 0 }, (err) => {
|
|
|
51
54
|
body: {
|
|
52
55
|
hello: 'world'
|
|
53
56
|
}
|
|
54
|
-
}, (err,
|
|
57
|
+
}, (err, _res, data) => {
|
|
55
58
|
t.error(err)
|
|
56
59
|
t.same(data, { something: 'else' })
|
|
57
60
|
})
|
|
@@ -32,7 +32,7 @@ const target = http.createServer((req, res) => {
|
|
|
32
32
|
})
|
|
33
33
|
})
|
|
34
34
|
|
|
35
|
-
instance.post('/', (
|
|
35
|
+
instance.post('/', (_request, reply) => {
|
|
36
36
|
reply.from(`http://localhost:${target.address().port}`, {
|
|
37
37
|
body: {
|
|
38
38
|
something: 'else'
|
|
@@ -55,7 +55,7 @@ instance.listen({ port: 0 }, (err) => {
|
|
|
55
55
|
body: {
|
|
56
56
|
hello: 'world'
|
|
57
57
|
}
|
|
58
|
-
}, (err,
|
|
58
|
+
}, (err, _res, data) => {
|
|
59
59
|
t.error(err)
|
|
60
60
|
t.same(data, { hello: 'fastify' })
|
|
61
61
|
})
|
|
@@ -32,7 +32,7 @@ const target = http.createServer((req, res) => {
|
|
|
32
32
|
})
|
|
33
33
|
})
|
|
34
34
|
|
|
35
|
-
instance.post('/', (
|
|
35
|
+
instance.post('/', (_request, reply) => {
|
|
36
36
|
reply.from(`http://localhost:${target.address().port}`, {
|
|
37
37
|
body: ''
|
|
38
38
|
})
|
|
@@ -53,7 +53,7 @@ instance.listen({ port: 0 }, (err) => {
|
|
|
53
53
|
body: {
|
|
54
54
|
hello: 'world'
|
|
55
55
|
}
|
|
56
|
-
}, (err,
|
|
56
|
+
}, (err, _res, data) => {
|
|
57
57
|
t.error(err)
|
|
58
58
|
t.same(data, { hello: 'fastify' })
|
|
59
59
|
})
|
|
@@ -32,7 +32,7 @@ const target = http.createServer((req, res) => {
|
|
|
32
32
|
})
|
|
33
33
|
})
|
|
34
34
|
|
|
35
|
-
instance.post('/', (
|
|
35
|
+
instance.post('/', (_request, reply) => {
|
|
36
36
|
reply.from(`http://localhost:${target.address().port}`, {
|
|
37
37
|
body: null
|
|
38
38
|
})
|
|
@@ -53,7 +53,7 @@ instance.listen({ port: 0 }, (err) => {
|
|
|
53
53
|
body: {
|
|
54
54
|
hello: 'world'
|
|
55
55
|
}
|
|
56
|
-
}, (err,
|
|
56
|
+
}, (err, _res, data) => {
|
|
57
57
|
t.error(err)
|
|
58
58
|
t.same(data, { hello: 'fastify' })
|
|
59
59
|
})
|
|
@@ -30,7 +30,7 @@ const target = http.createServer((req, res) => {
|
|
|
30
30
|
})
|
|
31
31
|
})
|
|
32
32
|
|
|
33
|
-
instance.post('/', (
|
|
33
|
+
instance.post('/', (_request, reply) => {
|
|
34
34
|
reply.from(`http://localhost:${target.address().port}`, {
|
|
35
35
|
body: {
|
|
36
36
|
something: 'else'
|
|
@@ -53,7 +53,7 @@ instance.listen({ port: 0 }, (err) => {
|
|
|
53
53
|
body: {
|
|
54
54
|
hello: 'world'
|
|
55
55
|
}
|
|
56
|
-
}, (err,
|
|
56
|
+
}, (err, _res, data) => {
|
|
57
57
|
t.error(err)
|
|
58
58
|
t.same(data, { hello: 'fastify' })
|
|
59
59
|
})
|
|
@@ -29,16 +29,16 @@ const target = http.createServer((req, res) => {
|
|
|
29
29
|
res.end(req.headers.host)
|
|
30
30
|
})
|
|
31
31
|
|
|
32
|
-
instance.get('/test', (
|
|
32
|
+
instance.get('/test', (_request, reply) => {
|
|
33
33
|
reply.from('/test', {
|
|
34
|
-
getUpstream: (
|
|
34
|
+
getUpstream: (_req, base) => {
|
|
35
35
|
t.pass('getUpstream called')
|
|
36
36
|
return `${base}:${target.address().port}`
|
|
37
37
|
}
|
|
38
38
|
})
|
|
39
39
|
})
|
|
40
40
|
|
|
41
|
-
instanceWithoutBase.get('/test2', (
|
|
41
|
+
instanceWithoutBase.get('/test2', (_request, reply) => {
|
|
42
42
|
reply.from('/test2', {
|
|
43
43
|
getUpstream: () => {
|
|
44
44
|
t.pass('getUpstream called')
|
|
@@ -20,7 +20,7 @@ const target = http.createServer((req, res) => {
|
|
|
20
20
|
res.end(req.headers.host)
|
|
21
21
|
})
|
|
22
22
|
|
|
23
|
-
instance.get('/test', (
|
|
23
|
+
instance.get('/test', (_request, reply) => {
|
|
24
24
|
reply.from('/test', {
|
|
25
25
|
getUpstream: () => {
|
|
26
26
|
t.pass('getUpstream called')
|
|
@@ -5,12 +5,6 @@ const Fastify = require('fastify')
|
|
|
5
5
|
const From = require('..')
|
|
6
6
|
const http = require('node:http')
|
|
7
7
|
const get = require('simple-get').concat
|
|
8
|
-
const semver = require('semver')
|
|
9
|
-
|
|
10
|
-
if (semver.gte(process.version, '20.2.0')) {
|
|
11
|
-
t.comment('skip this test on node >= 20.2.0 as it is current broken')
|
|
12
|
-
process.exit(0)
|
|
13
|
-
}
|
|
14
8
|
|
|
15
9
|
const instance = Fastify()
|
|
16
10
|
|
|
@@ -29,7 +23,7 @@ const target = http.createServer((req, res) => {
|
|
|
29
23
|
res.end('hello world')
|
|
30
24
|
})
|
|
31
25
|
|
|
32
|
-
instance.head('/', (
|
|
26
|
+
instance.head('/', (_request, reply) => {
|
|
33
27
|
t.pass('head received')
|
|
34
28
|
reply.from()
|
|
35
29
|
})
|
package/test/host-header.test.js
CHANGED
|
@@ -12,12 +12,12 @@ test('hostname', async (t) => {
|
|
|
12
12
|
|
|
13
13
|
nock('http://httpbin.org')
|
|
14
14
|
.get('/ip')
|
|
15
|
-
.reply(200, function (
|
|
15
|
+
.reply(200, function () {
|
|
16
16
|
t.equal(this.req.headers.host, 'httpbin.org')
|
|
17
17
|
return { origin: '127.0.0.1' }
|
|
18
18
|
})
|
|
19
19
|
|
|
20
|
-
instance.get('*', (
|
|
20
|
+
instance.get('*', (_request, reply) => {
|
|
21
21
|
reply.from(null, {
|
|
22
22
|
rewriteRequestHeaders: (originalReq, headers) => {
|
|
23
23
|
t.equal(headers.host, 'httpbin.org')
|
|
@@ -48,7 +48,7 @@ test('hostname and port', async (t) => {
|
|
|
48
48
|
|
|
49
49
|
nock('http://httpbin.org:8080')
|
|
50
50
|
.get('/ip')
|
|
51
|
-
.reply(200, function (
|
|
51
|
+
.reply(200, function () {
|
|
52
52
|
t.equal(this.req.headers.host, 'httpbin.org:8080')
|
|
53
53
|
return { origin: '127.0.0.1' }
|
|
54
54
|
})
|
|
@@ -58,7 +58,7 @@ test('hostname and port', async (t) => {
|
|
|
58
58
|
http: true
|
|
59
59
|
})
|
|
60
60
|
|
|
61
|
-
instance.get('*', (
|
|
61
|
+
instance.get('*', (_request, reply) => {
|
|
62
62
|
reply.from()
|
|
63
63
|
})
|
|
64
64
|
|
package/test/http-agents.test.js
CHANGED
package/test/http-http2.test.js
CHANGED
|
@@ -14,14 +14,14 @@ test('http -> http2', async (t) => {
|
|
|
14
14
|
http2: true
|
|
15
15
|
})
|
|
16
16
|
|
|
17
|
-
target.get('/', (
|
|
17
|
+
target.get('/', (_request, reply) => {
|
|
18
18
|
t.pass('request proxied')
|
|
19
19
|
reply.code(404).header('x-my-header', 'hello!').send({
|
|
20
20
|
hello: 'world'
|
|
21
21
|
})
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
-
instance.get('/', (
|
|
24
|
+
instance.get('/', (_request, reply) => {
|
|
25
25
|
reply.from()
|
|
26
26
|
})
|
|
27
27
|
|
package/test/http-retry.test.js
CHANGED
|
@@ -29,7 +29,7 @@ test('Will retry', async function (t) {
|
|
|
29
29
|
|
|
30
30
|
instance.register(From, { http: true })
|
|
31
31
|
|
|
32
|
-
instance.get('/', (
|
|
32
|
+
instance.get('/', (_request, reply) => {
|
|
33
33
|
reply.from(`http://localhost:${target.address().port}/`, {
|
|
34
34
|
retriesCount: 1,
|
|
35
35
|
onError: (reply, { error }) => {
|
|
@@ -56,7 +56,7 @@ test('will not retry', async function (t) {
|
|
|
56
56
|
|
|
57
57
|
instance.register(From, { http: true })
|
|
58
58
|
|
|
59
|
-
instance.get('/', (
|
|
59
|
+
instance.get('/', (_request, reply) => {
|
|
60
60
|
reply.from(`http://localhost:${target.address().port}/`, {
|
|
61
61
|
retriesCount: 0,
|
|
62
62
|
onError: (reply, { error }) => {
|
|
@@ -87,7 +87,7 @@ test('will not retry unsupported method', async function (t) {
|
|
|
87
87
|
|
|
88
88
|
instance.register(From, { http: true, retryMethods: ['DELETE'] })
|
|
89
89
|
|
|
90
|
-
instance.get('/', (
|
|
90
|
+
instance.get('/', (_request, reply) => {
|
|
91
91
|
reply.from(`http://localhost:${target.address().port}/`, {
|
|
92
92
|
retriesCount: 1,
|
|
93
93
|
onError: (reply, { error }) => {
|
|
@@ -12,7 +12,7 @@ test('http request timeout', async (t) => {
|
|
|
12
12
|
const target = Fastify()
|
|
13
13
|
t.teardown(target.close.bind(target))
|
|
14
14
|
|
|
15
|
-
target.get('/', (
|
|
15
|
+
target.get('/', (_request, reply) => {
|
|
16
16
|
t.pass('request arrives')
|
|
17
17
|
|
|
18
18
|
clock.setTimeout(() => {
|
|
@@ -28,7 +28,7 @@ test('http request timeout', async (t) => {
|
|
|
28
28
|
|
|
29
29
|
instance.register(From, { http: { requestOptions: { timeout: 100 } } })
|
|
30
30
|
|
|
31
|
-
instance.get('/', (
|
|
31
|
+
instance.get('/', (_request, reply) => {
|
|
32
32
|
reply.from(`http://localhost:${target.server.address().port}/`)
|
|
33
33
|
})
|
|
34
34
|
|
|
@@ -56,7 +56,7 @@ test('http sse removes timeout test', async (t) => {
|
|
|
56
56
|
const target = Fastify()
|
|
57
57
|
t.teardown(target.close.bind(target))
|
|
58
58
|
|
|
59
|
-
target.get('/', (
|
|
59
|
+
target.get('/', (_request, reply) => {
|
|
60
60
|
t.pass('request arrives')
|
|
61
61
|
|
|
62
62
|
reply.header('content-type', 'text/event-stream').status(200).send('hello world')
|
|
@@ -69,7 +69,7 @@ test('http sse removes timeout test', async (t) => {
|
|
|
69
69
|
|
|
70
70
|
instance.register(From, { http: { requestOptions: { timeout: 100 } } })
|
|
71
71
|
|
|
72
|
-
instance.get('/', (
|
|
72
|
+
instance.get('/', (_request, reply) => {
|
|
73
73
|
reply.from(`http://localhost:${target.server.address().port}/`)
|
|
74
74
|
})
|
|
75
75
|
|
package/test/http2-http2.test.js
CHANGED
|
@@ -23,14 +23,14 @@ t.test('http2 -> http2', async (t) => {
|
|
|
23
23
|
http2: true
|
|
24
24
|
})
|
|
25
25
|
|
|
26
|
-
target.get('/', (
|
|
26
|
+
target.get('/', (_request, reply) => {
|
|
27
27
|
t.pass('request proxied')
|
|
28
28
|
reply.code(404).header('x-my-header', 'hello!').send({
|
|
29
29
|
hello: 'world'
|
|
30
30
|
})
|
|
31
31
|
})
|
|
32
32
|
|
|
33
|
-
instance.get('/', (
|
|
33
|
+
instance.get('/', (_request, reply) => {
|
|
34
34
|
reply.from()
|
|
35
35
|
})
|
|
36
36
|
|
package/test/http2-https.test.js
CHANGED
|
@@ -25,14 +25,14 @@ const target = Fastify({
|
|
|
25
25
|
https: certs
|
|
26
26
|
})
|
|
27
27
|
|
|
28
|
-
target.get('/', (
|
|
28
|
+
target.get('/', (_request, reply) => {
|
|
29
29
|
t.pass('request proxied')
|
|
30
30
|
reply.code(404).header('x-my-header', 'hello!').send({
|
|
31
31
|
hello: 'world'
|
|
32
32
|
})
|
|
33
33
|
})
|
|
34
34
|
|
|
35
|
-
instance.get('/', (
|
|
35
|
+
instance.get('/', (_request, reply) => {
|
|
36
36
|
reply.from()
|
|
37
37
|
})
|
|
38
38
|
|
|
@@ -14,14 +14,14 @@ test('http -> http2 crash', async (t) => {
|
|
|
14
14
|
http2: true
|
|
15
15
|
})
|
|
16
16
|
|
|
17
|
-
target.get('/', (
|
|
17
|
+
target.get('/', (_request, reply) => {
|
|
18
18
|
t.pass('request proxied')
|
|
19
19
|
reply.code(200).send({
|
|
20
20
|
hello: 'world'
|
|
21
21
|
})
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
-
instance.get('/', (
|
|
24
|
+
instance.get('/', (_request, reply) => {
|
|
25
25
|
reply.from()
|
|
26
26
|
})
|
|
27
27
|
|
|
@@ -23,7 +23,7 @@ test('http2 request timeout disabled', async (t) => {
|
|
|
23
23
|
http2: { requestTimeout: 0, sessionTimeout: 16000 }
|
|
24
24
|
})
|
|
25
25
|
|
|
26
|
-
instance.get('/', (
|
|
26
|
+
instance.get('/', (_request, reply) => {
|
|
27
27
|
reply.from(`http://localhost:${target.server.address().port}/`)
|
|
28
28
|
})
|
|
29
29
|
|
|
@@ -59,7 +59,7 @@ test('http2 session timeout disabled', async (t) => {
|
|
|
59
59
|
http2: { requestTimeout: 0, sessionTimeout: 0 }
|
|
60
60
|
})
|
|
61
61
|
|
|
62
|
-
instance.get('/', (
|
|
62
|
+
instance.get('/', (_request, reply) => {
|
|
63
63
|
reply.from(`http://localhost:${target.server.address().port}/`)
|
|
64
64
|
})
|
|
65
65
|
|
|
@@ -23,7 +23,7 @@ test('http2 request timeout', async (t) => {
|
|
|
23
23
|
http2: { requestTimeout: 100, sessionTimeout: 6000 }
|
|
24
24
|
})
|
|
25
25
|
|
|
26
|
-
instance.get('/', (
|
|
26
|
+
instance.get('/', (_request, reply) => {
|
|
27
27
|
reply.from(`http://localhost:${target.server.address().port}/`)
|
|
28
28
|
})
|
|
29
29
|
|
|
@@ -67,7 +67,7 @@ test('http2 session timeout', async (t) => {
|
|
|
67
67
|
http2: { sessionTimeout: 100 }
|
|
68
68
|
})
|
|
69
69
|
|
|
70
|
-
instance.get('/', (
|
|
70
|
+
instance.get('/', (_request, reply) => {
|
|
71
71
|
reply.from(`http://localhost:${target.server.address().port}/`)
|
|
72
72
|
})
|
|
73
73
|
|
|
@@ -96,7 +96,7 @@ test('http2 session timeout', async (t) => {
|
|
|
96
96
|
test('http2 sse removes request and session timeout test', async (t) => {
|
|
97
97
|
const target = Fastify({ http2: true, sessionTimeout: 0 })
|
|
98
98
|
|
|
99
|
-
target.get('/', (
|
|
99
|
+
target.get('/', (_request, reply) => {
|
|
100
100
|
t.pass('request arrives')
|
|
101
101
|
|
|
102
102
|
reply.status(200).header('content-type', 'text/event-stream').send('hello world')
|
|
@@ -111,7 +111,7 @@ test('http2 sse removes request and session timeout test', async (t) => {
|
|
|
111
111
|
http2: { sessionTimeout: 100 }
|
|
112
112
|
})
|
|
113
113
|
|
|
114
|
-
instance.get('/', (
|
|
114
|
+
instance.get('/', (_request, reply) => {
|
|
115
115
|
reply.from(`http://localhost:${target.server.address().port}/`)
|
|
116
116
|
})
|
|
117
117
|
|
package/test/method.test.js
CHANGED
|
@@ -33,7 +33,7 @@ const target = http.createServer((req, res) => {
|
|
|
33
33
|
})
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
-
instance.patch('/', (
|
|
36
|
+
instance.patch('/', (_request, reply) => {
|
|
37
37
|
reply.from(`http://localhost:${target.address().port}`, { method: 'POST' })
|
|
38
38
|
})
|
|
39
39
|
|
|
@@ -42,7 +42,7 @@ t.teardown(target.close.bind(target))
|
|
|
42
42
|
target.listen({ port: 0 }, (err) => {
|
|
43
43
|
t.error(err)
|
|
44
44
|
|
|
45
|
-
instance.addContentTypeParser('application/json', function (
|
|
45
|
+
instance.addContentTypeParser('application/json', function (_req, payload, done) {
|
|
46
46
|
done(null, payload)
|
|
47
47
|
})
|
|
48
48
|
|
|
@@ -61,7 +61,7 @@ target.listen({ port: 0 }, (err) => {
|
|
|
61
61
|
'content-type': 'application/json'
|
|
62
62
|
},
|
|
63
63
|
body: bodyString
|
|
64
|
-
}, (err,
|
|
64
|
+
}, (err, _res, data) => {
|
|
65
65
|
t.error(err)
|
|
66
66
|
const parsed = JSON.parse(data)
|
|
67
67
|
t.same(parsed, { something: 'else' })
|