header-overflow.test.js — fastify Source File
Architecture documentation for header-overflow.test.js, a javascript file in the fastify codebase.
Entity Profile
Source Code
'use strict'
const { test } = require('node:test')
const Fastify = require('..')
const maxHeaderSize = 1024
test('Should return 431 if request header fields are too large', async (t) => {
t.plan(2)
const fastify = Fastify({ http: { maxHeaderSize } })
fastify.route({
method: 'GET',
url: '/',
handler: (_req, reply) => {
reply.send({ hello: 'world' })
}
})
const fastifyServer = await fastify.listen({ port: 0 })
const result = await fetch(fastifyServer, {
method: 'GET',
headers: {
'Large-Header': 'a'.repeat(maxHeaderSize)
}
})
t.assert.ok(!result.ok)
t.assert.strictEqual(result.status, 431)
t.after(() => fastify.close())
})
test('Should return 431 if URI is too long', async (t) => {
t.plan(2)
const fastify = Fastify({ http: { maxHeaderSize } })
fastify.route({
method: 'GET',
url: '/',
handler: (_req, reply) => {
reply.send({ hello: 'world' })
}
})
const fastifyServer = await fastify.listen({ port: 0 })
const result = await fetch(`${fastifyServer}/${'a'.repeat(maxHeaderSize)}`)
t.assert.ok(!result.ok)
t.assert.strictEqual(result.status, 431)
t.after(() => fastify.close())
})
Source
Frequently Asked Questions
What does header-overflow.test.js do?
header-overflow.test.js is a source file in the fastify codebase, written in javascript.
Where is header-overflow.test.js in the architecture?
header-overflow.test.js is located at test/header-overflow.test.js (directory: test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free