Skip to content

Suggestion: Make Body.fromString default to returning HTML documents #190

Closed

Description

@vlidholt

Currently, creating a default body will set the MIME type to text/plain, which seems to be a rather uncommon use case. Perhaps. the default should instead be MimeType.html (text/html). This would make the API behave a tad bit more as expected.

Activity

  1. nielsenko commented on Oct 7, 2025

    @nielsenko
    Collaborator

    Perhaps it would be better to use a MimeTypeResolver (from package mime) in case no mime-type is set.

  2. vlidholt commented on Oct 7, 2025

    @vlidholt
    ContributorAuthor

    From the mime docs:

    The MimeTypeResolver class can be used to determine the MIME type of a file. It supports both using the extension of the file name and looking at magic bytes from the beginning of the file.

    This seems not to be applicable to other things than files? It doesn't look at the content (other than the magic bytes).

  3. nielsenko commented on Oct 8, 2025

    @nielsenko
    Collaborator

    This seems not to be applicable to other things than files? It doesn't look at the content (other than the magic bytes).

    If you pass an empty file-name it will look at just the header bytes. However, TIL it works only for binary mime-types. For text/* mime-types you need something different.

  4. self-assigned this
    on Oct 8, 2025
  5. moved this from Inbox 📫 to In Progress 🔥 in Serverpod Frameworkson Oct 8, 2025
  6. added
    area: headers
    ux
    on Oct 8, 2025
  7. moved this from In Progress 🔥 to Done 🚀 in Serverpod Frameworkson Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: headersux

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions