Skip to content

feat: add contentType option#93

Merged
Fdawgs merged 3 commits intomasterfrom
feat/content-type
Nov 22, 2024
Merged

feat: add contentType option#93
Fdawgs merged 3 commits intomasterfrom
feat/content-type

Conversation

@Fdawgs
Copy link
Copy Markdown
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
Copy link
Copy Markdown

Copilot AI left a comment

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
Copy Markdown
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
Copy Markdown
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

@Fdawgs Fdawgs requested a review from gurgunday November 19, 2024 16:44
Signed-off-by: Frazer Smith <[email protected]>
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

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

@Fdawgs Fdawgs merged commit 277a32f into master Nov 22, 2024
@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.

5 participants