Skip to content

Commit 4d46bd8

Browse files
committed
test: GET endpoints should respond to HEAD reqs
1 parent 5ae7e0f commit 4d46bd8

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

integration/hello-world/e2e/express-instance.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ describe('Hello world (express instance)', () => {
4545
});
4646
});
4747

48+
it('/HEAD should respond to with a 200', () => {
49+
return request(server).head('/hello').expect(200);
50+
});
51+
4852
afterEach(async () => {
4953
await app.close();
5054
});

integration/hello-world/e2e/fastify-adapter.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ describe('Hello world (fastify adapter)', () => {
8787
.then(({ payload }) => expect(payload).to.be.eql('Hello world!'));
8888
});
8989

90+
it('/HEAD should respond to with a 200', () => {
91+
return app
92+
.inject({
93+
method: 'HEAD',
94+
url: '/hello',
95+
})
96+
.then(({ statusCode }) => expect(statusCode).to.be.eq(200));
97+
});
98+
9099
afterEach(async () => {
91100
await app.close();
92101
});

packages/platform-fastify/adapters/fastify-adapter.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,10 @@ export class FastifyAdapter<
682682
return rawRequest.originalUrl || rawRequest.url;
683683
}
684684

685-
private injectRouteOptions(routerMethodKey: HTTPMethods, ...args: any[]) {
685+
private injectRouteOptions(
686+
routerMethodKey: Uppercase<HTTPMethods>,
687+
...args: any[]
688+
) {
686689
const handlerRef = args[args.length - 1];
687690
const isVersioned =
688691
!isUndefined(handlerRef.version) &&

0 commit comments

Comments
 (0)