@fastify/reply-from 8.4.0 → 8.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastify/reply-from",
3
- "version": "8.4.0",
3
+ "version": "8.4.2",
4
4
  "description": "forward your HTTP request to another server, for fastify",
5
5
  "main": "index.js",
6
6
  "types": "types/index.d.ts",
@@ -55,7 +55,7 @@
55
55
  "fastify-plugin": "^4.0.0",
56
56
  "pump": "^3.0.0",
57
57
  "tiny-lru": "^10.0.0",
58
- "undici": "^5.5.1"
58
+ "undici": "^5.19.1"
59
59
  },
60
60
  "pre-commit": [
61
61
  "lint",
@@ -0,0 +1,57 @@
1
+ 'use strict'
2
+
3
+ const t = require('tap')
4
+ const Fastify = require('fastify')
5
+ const get = require('simple-get').concat
6
+ const From = require('..')
7
+
8
+ const header = 'attachment; filename="år.pdf"'
9
+
10
+ t.plan(6)
11
+
12
+ const instance = Fastify()
13
+ t.teardown(instance.close.bind(instance))
14
+ const proxy1 = Fastify()
15
+ t.teardown(proxy1.close.bind(proxy1))
16
+ const proxy2 = Fastify()
17
+ t.teardown(proxy2.close.bind(proxy2))
18
+
19
+ instance.get('/', (request, reply) => {
20
+ reply.header('content-disposition', header).send('OK')
21
+ })
22
+
23
+ proxy1.register(From, {
24
+ undici: {
25
+ keepAliveMaxTimeout: 10
26
+ }
27
+ })
28
+ proxy1.get('/', (request, reply) => {
29
+ return reply.from(`http://localhost:${instance.server.address().port}`)
30
+ })
31
+
32
+ proxy2.register(From, {
33
+ undici: {
34
+ keepAliveMaxTimeout: 10
35
+ }
36
+ })
37
+ proxy2.get('/', (request, reply) => {
38
+ return reply.from(`http://localhost:${proxy1.server.address().port}`)
39
+ })
40
+
41
+ instance.listen({ port: 0 }, err => {
42
+ t.error(err)
43
+
44
+ proxy1.listen({ port: 0 }, err => {
45
+ t.error(err)
46
+
47
+ proxy2.listen({ port: 0 }, err => {
48
+ t.error(err)
49
+
50
+ get(`http://localhost:${proxy2.server.address().port}`, (err, res, data) => {
51
+ t.error(err)
52
+ t.equal(res.statusCode, 200)
53
+ t.equal(data.toString(), 'OK')
54
+ })
55
+ })
56
+ })
57
+ })