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

Reply's content-type header value suffix stripped when charset is omitted #3788

Closed
2 tasks done
JakobJingleheimer opened this issue Mar 21, 2022 · 2 comments · Fixed by #3789
Closed
2 tasks done

Reply's content-type header value suffix stripped when charset is omitted #3788

JakobJingleheimer opened this issue Mar 21, 2022 · 2 comments · Fixed by #3789

Comments

@JakobJingleheimer
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

3.27.4

Plugin version

No response

Node.js version

17.7.2

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

12.2

Description

In the example here, fastify strips ; version=2 (and appends ; charset=utf-8) when reply.send() is called.

Steps to Reproduce

Bad:

reply.header(
  'Content-Type',
  `application/vnd.example.com+json; version=2`,
);

reply.send({ foo: 'bar' });

fastify.log.info(reply.getHeaders());
// content-type: application/vnd.example.com+json; charset=utf-8

Good:

reply.header(
  'Content-Type',
  `application/vnd.example.com+json; version=2; charset=utf-8`,
);

reply.send({ foo: 'bar' });

fastify.log.info(reply.getHeaders());
// content-type: application/vnd.example.com+json; version=2; charset=utf-8

Expected Behavior

The existing suffix should not be stripped and ; charset=utf-8 should be appended after.

@xtx1130
Copy link
Contributor

xtx1130 commented Mar 22, 2022

Seems like this pr #2315 has a problem, I will take a look

xtx1130 added a commit to xtx1130/fastify that referenced this issue Mar 22, 2022
@Eomm Eomm linked a pull request Mar 22, 2022 that will close this issue
4 tasks
mcollina pushed a commit that referenced this issue Mar 22, 2022
* fix: bug fix #3788

* test: delete unref, use teardown instead
@JakobJingleheimer
Copy link
Author

Wow! Thanks for the fast turnaround!

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 a pull request may close this issue.

2 participants