WebAssembly / WebAssembly/WASI

Stream `media_type` should be Option<String>

Open
#491 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

S-inactive
Dominant language
Rust
Stars
5.8k
Forks
333
Avg merge
2d 13h
Merged PRs (30d)
3

Description

input_media_type and output_media_type mention:

Returns */* if the Media Type is unknown.

As far as I know, in the world of HTTP the string "*/*" is only used as a wildcard in places where a content type filter is expected (Accept header), indicating any content type will do. It is never used as a content type accompanying actual data. For these scenario's where the content type is unknown, "application/octet-stream" is generally used.

Additionally, according to RFC-7231 the content type should preferably not be set at all:

A sender that generates a message containing a payload body SHOULD generate a Content-Type header field in that message unless the intended media type of the enclosed representation is unknown to the sender. If a Content-Type header field is not present, the recipient MAY either assume a media type of "application/octet-stream" or examine the data to determine its type.

That leads me to think input_media_type & output_media_type should be changed to be an Option type returning None if the content type is unknown. Alternative solution would be to return an empty string, or "application/octet-stream". But not "*/*".

References:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the input_media_type and output_media_type implementations and their callers. Review how unknown media types are currently represented, including any tests or documentation describing /, and compare the behavior with RFC 7231 section 3.1.1.5. Done means the API's unknown-media-type behavior is agreed, consistently implemented, and covered by updated callers and tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.