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

feat: add contentType option #93

Merged
merged 3 commits into from
Nov 22, 2024
Merged

feat: add contentType option #93

merged 3 commits into from
Nov 22, 2024

Conversation

Fdawgs
Copy link
Member

@Fdawgs Fdawgs commented Nov 19, 2024

This PR adds the ability to disable the Content-Type response header via the contentType option.

Whilst the automatic setting of the Content-Type response header is great, it's not always right for some edge cases, such as for vendor-specific or proprietary extensions.

Likewise, the charset is hardcoded to utf-8 for text/plain, text/html and application/json files; these types can support more than just utf-8 character encoded content so it'd be nice to get around that.

Related to fastify/fastify-static#480.

Checklist

@Fdawgs Fdawgs requested a review from Copilot November 19, 2024 15:17

Choose a reason for hiding this comment

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no suggestions.

@Fdawgs
Copy link
Member Author

Fdawgs commented Nov 19, 2024

Should I just add a new test block to the types tests or add contentType: true to one of the existing ones?

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 except the type test

I think you can add it to an existing test as well, both should be fine

README.md Outdated Show resolved Hide resolved
Signed-off-by: Frazer Smith <[email protected]>
Copy link
Member

@dancastillo dancastillo left a comment

Choose a reason for hiding this comment

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

LGTM

@Fdawgs
Copy link
Member Author

Fdawgs commented Nov 21, 2024

Any thoughts on this @climba03003? I know you've worked a lot on the rewrite of this module so didn't want to go ahead and merge without your input!

Copy link
Member

@climba03003 climba03003 left a comment

Choose a reason for hiding this comment

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

I am thinking the needs of disable option.
Since this library is just provides whatever information the consumer needs, it is up to the consumer to decide if he / she want what header.
It is a bit overkill provide an option to disable feature. (The function here is just a giant map lookup. Should not be costly.)

@Fdawgs
Copy link
Member Author

Fdawgs commented Nov 22, 2024

I am thinking the needs of disable option. Since this library is just provides whatever information the consumer needs, it is up to the consumer to decide if he / she want what header. It is a bit overkill provide an option to disable feature. (The function here is just a giant map lookup. Should not be costly.)

So... is that a tentative approval? 😆

@climba03003
Copy link
Member

Yes, but I do believe @fastify/static require it's own fix.

@Fdawgs Fdawgs merged commit 277a32f into master Nov 22, 2024
16 checks passed
@Fdawgs Fdawgs deleted the feat/content-type branch November 22, 2024 10:19
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.

4 participants