Conversation
🦋 Changeset detectedLatest commit: 0d11fe4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
5 tasks
Contributor
|
This will prevent it from failing if the header has directives attached to it if (!content_type) return true; // defaults to json
const [type] = content_type.split(';'); // get the mime type
return (
type === 'text/plain' ||
type === 'application/json' ||
type === 'application/x-www-form-urlencoded' ||
type === 'multipart/form-data'
); |
JeanJPNM
reviewed
Jul 12, 2021
Member
Author
|
Thanks for taking a look @JeanJPNM ! Both good suggestions! |
Contributor
|
@benmccann, with this change, an endpoint in my app which returns Should |
Contributor
|
Well, currently you can use a workaround: export const get = () => {
const body = "<foo />";
return {
status: 200,
headers: { "content-type": "application/xml" },
body: new TextEncoder().encode(body),
};
}; |
Member
Author
|
I sent a fix here: #1900 |
Contributor
|
@JeanJPNM @benmccann thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In response to @drzax's comment (https://github.com/sveltejs/kit/pull/1687/files#r667643869) it occurs to me that the way we're treating body content type is a bit backwards. We should treat is as bytes unless it's a known type. The user can always convert bytes into whatever they're expecting. But if we try to treat it as text unless we detect a known
content-type, we're doomed to failure since it would be hard to create a super exhaustive list of mime types to ensure we're handling them all correctly(This is PR aligns with how Play Framework works, which is one of the web frameworks I'm most familiar with. It also aligns with how our own
parse_bodyworks)