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

feat: add media_types #2286

Merged
merged 5 commits into from
May 31, 2022
Merged

feat: add media_types #2286

merged 5 commits into from
May 31, 2022

Conversation

kitsonk
Copy link
Contributor

@kitsonk kitsonk commented May 30, 2022

Once upon a time deno.land/x/media_types was inside std but it was removed due to there being a debate about the API and I took over maintaining it.

The PR intends to reverse this and will result in a series of PRs brining some of the common APIs common to handling HTTP requests into the std library.

@lucacasonato this includes the GoLang mime package APIs as well as some parts of the jshttp/mime-types APIs that deno.land/x/media_types was based on. It should provide an easy migration path for users of deno.land/x/media_types but also provide more logical APIs aligned to what is in GoLang.

Once this is landed, a subsequent PR should be created so the fileserver uses this instead of it partial mime db. I will also refactor oak and my other projects to use this as well.

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kt3k
Copy link
Member

kt3k commented May 30, 2022

FYI Luca and I worked together on a similar API last week, which resulted in #2276 (which only suggests contentType API in std/mime

media_types/mod.ts Outdated Show resolved Hide resolved
@kt3k
Copy link
Member

kt3k commented May 31, 2022

Question about the module name: Should we call this std/media_types or std/mime?

Golang, for example, name the module mime instead of media_types. Also MDN seems calling it MIME types more times than media types ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types (also the page title and URL has MIME instead of media type

@kitsonk
Copy link
Contributor Author

kitsonk commented May 31, 2022

Question about the module name: Should we call this std/media_types or std/mime?

Golang, for example, name the module mime instead of media_types. Also MDN seems calling it MIME types more times than media types ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types (also the page title and URL has MIME instead of media type

MIME is an antiquated name for media types. When it was originally part of std, it was called media_types and moved out to deno.land/x as media_types, so my feeling is it should come back as media_types, especially because we want people to move back from deno.land/x/media_types to this.

While it is less common it is the proper name for them (as there is no mail interchange going on here). From the page you linked to:

A media type (also known as a Multipurpose Internet Mail Extensions or MIME type) indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.

And the standard they are based on says:

Media Type Specifications and Registration Procedures

This document defines procedures for the specification and registration of media types for use in HTTP, MIME, and other Internet protocols.

So MIME is an extension to the e-mail protocol, a MIME type is when you use a media type with MIME and the Content-Type and Content-Disposition headers of HTTP use a media type.

@kt3k
Copy link
Member

kt3k commented May 31, 2022

While it is less common it is the proper name for them (as there is no mail interchange going on here)

So MIME is an extension to the e-mail protocol, a MIME type is when you use a media type with MIME and the Content-Type and Content-Disposition headers of HTTP use a media type.

Sounds fair enough to me

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kitsonk kitsonk merged commit ae22ac4 into denoland:main May 31, 2022
@kitsonk kitsonk deleted the feat_media_types branch May 31, 2022 22:43
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.

None yet

3 participants