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

Add a comprehensive MIME registry #4632

Closed
straight-shoota opened this issue Jun 28, 2017 · 7 comments
Closed

Add a comprehensive MIME registry #4632

straight-shoota opened this issue Jun 28, 2017 · 7 comments

Comments

@straight-shoota
Copy link
Member

straight-shoota commented Jun 28, 2017

@asterite on #2470 (comment):

We should probably have some Mime class/module as a registry for this, similar to Go's (since we provide an HTTP::Server in the standard library we will probably want this in the standard library too).

There are three shards who provide a MIME registry:

And ysbaddaden/frost has a extensive MIME registry.

They all rely on a custom mime type database in form of a JSON file included in the shard. While this can be required in some cases, I feel like the stdlib implementation should probably just rely on the mime types registry of the operating system (like the Go example).

@asterite
Copy link
Member

We can start with a Mime registry with some default extensions and a way to add more extensions to the registry. Then in a separate PR we could load mime types from the OS if available.

@asterite
Copy link
Member

And the existing shards would just add to the standard registry instead of providing alternative registries.

@ysbaddaden
Copy link
Contributor

Note that on linux (at least debian/ubuntu) a mime type database can usually be found at /etc/mime.types as a list of:

# comment
mime/type    ext ext2 ext3

@RX14
Copy link
Contributor

RX14 commented Jan 18, 2018

Perhaps an official shard to add magic-guessing to the registry too wouldn't be a terrible idea.

@asterite
Copy link
Member

Go uses:

var typeFiles = []string{
  	"/etc/mime.types",
  	"/etc/apache2/mime.types",
  	"/etc/apache/mime.types",
}

@ysbaddaden
Copy link
Contributor

Perhaps an official shard to add magic-guessing to the registry too wouldn't be a terrible idea.

Perhaps it should be in stdlib, or the whole mime registry be a mime-types shard (nothing in stdlib).

Go has a bunch of locations for each platform (windows registry, different places across the filesystem on posix systems):
https://golang.org/src/mime/

@straight-shoota
Copy link
Member Author

As long as HTTP::Server is in the standard library, it also needs a MIME registry.
I agree that it should have a small set of default mime types baked in, try to load a mime database from known system locations and provide a means to add/change mime type entries programatically. Maybe even allow to load a mime type database from a customizable path, similar to the customizable timezone database location using ENV["ZONEINFO"] (though this probably shouldn't use an environment variable).

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

No branches or pull requests

4 participants