-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: undici headers * test: fix multiple listen * test: provide undici option * test: use keepAliveMaxTimeout 10 * chore: update comment Co-authored-by: Simen Bekkhus <[email protected]> --------- Co-authored-by: Simen Bekkhus <[email protected]>
- Loading branch information
1 parent
b30a4fe
commit 09cb8e7
Showing
3 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use strict' | ||
|
||
const t = require('tap') | ||
const Fastify = require('fastify') | ||
const get = require('simple-get').concat | ||
const From = require('..') | ||
|
||
const header = 'attachment; filename="år.pdf"' | ||
|
||
t.plan(6) | ||
|
||
const instance = Fastify() | ||
t.teardown(instance.close.bind(instance)) | ||
const proxy1 = Fastify() | ||
t.teardown(proxy1.close.bind(proxy1)) | ||
const proxy2 = Fastify() | ||
t.teardown(proxy2.close.bind(proxy2)) | ||
|
||
instance.get('/', (request, reply) => { | ||
reply.header('content-disposition', header).send('OK') | ||
}) | ||
|
||
proxy1.register(From, { | ||
undici: { | ||
keepAliveMaxTimeout: 10 | ||
} | ||
}) | ||
proxy1.get('/', (request, reply) => { | ||
return reply.from(`http://localhost:${instance.server.address().port}`) | ||
}) | ||
|
||
proxy2.register(From, { | ||
undici: { | ||
keepAliveMaxTimeout: 10 | ||
} | ||
}) | ||
proxy2.get('/', (request, reply) => { | ||
return reply.from(`http://localhost:${proxy1.server.address().port}`) | ||
}) | ||
|
||
instance.listen({ port: 0 }, err => { | ||
t.error(err) | ||
|
||
proxy1.listen({ port: 0 }, err => { | ||
t.error(err) | ||
|
||
proxy2.listen({ port: 0 }, err => { | ||
t.error(err) | ||
|
||
get(`http://localhost:${proxy2.server.address().port}`, (err, res, data) => { | ||
t.error(err) | ||
t.equal(res.statusCode, 200) | ||
t.equal(data.toString(), 'OK') | ||
}) | ||
}) | ||
}) | ||
}) |