Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wildcard head return content-length header #448

Merged
merged 1 commit into from
Apr 4, 2024

Conversation

climba03003
Copy link
Member

@climba03003 climba03003 commented Apr 3, 2024

Fixes #447

The reason behind we should not use exposeHeadRoute is that inside pumpSendToReply, we never provide payload for HEAD route. So, fastify think it is providing empty response and override the Content-Length unexpectedly.

Checklist

@gurgunday
Copy link
Member

Haha, you are fast ;)

Thanks for the PR, you are right

Copy link
Member

@gurgunday gurgunday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@gurgunday
Copy link
Member

Can you release a patch?

@climba03003
Copy link
Member Author

Can you release a patch?

I can, but most of the time I will wait for two approval before merge.

@@ -1740,7 +1740,7 @@ t.test('with fastify-compress', t => {
})
})
t.test('register /static/ with schemaHide true', t => {
t.plan(4)
t.plan(3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? There weren't unfinished test errors before?

Copy link
Member Author

@climba03003 climba03003 Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we no longer have GET and HEAD registered separately.
FYI: The internal HEAD route also trigger onRoute hook.

@gurgunday gurgunday requested review from Eomm and Fdawgs April 3, 2024 10:06
@climba03003 climba03003 merged commit 85f0831 into master Apr 4, 2024
21 checks passed
@climba03003 climba03003 deleted the fix-wildcard-head branch April 4, 2024 02:18
@gurgunday
Copy link
Member

gurgunday commented Apr 4, 2024

@climba03003 this looks like a problem in Fastify too, no? A HEAD route (that's linked to a GET route) should automatically calculate and send the header Content-Length while stripping the body IMO

What do you think?

@climba03003
Copy link
Member Author

climba03003 commented Apr 4, 2024

this looks like a problem in Fastify too, no?

No, as described in the PR @fastify/static are sending empty string or undefined in HEAD route.
So, the core imagine you sending nothing and correct the Content-Length.

The automatic one requires to always send the actual payload otherwise it can not calculate properly.

@gurgunday
Copy link
Member

Okay, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTP HEAD can not get the content-length(always 0)
3 participants