Skip to content

Commit

Permalink
Add known media types and extensions.
Browse files Browse the repository at this point in the history
Adds the following to the list of known media types:

  * audio/webm (WEBA)
  * image/tiff (TIFF)
  * audio/aac (AAC)
  * text/calendar (Calendar)
  * video/mpeg (MPEG)
  * application/x-tar (TAR)
  * application/gzip (GZIP)
  * video/quicktime (MOV)
  * video/mp4 (MP4)

Also adds the following to the list of known extensions:

  * .weba (WEBA)
  * .ogv (OGG)
  * .mp4 (MP4)
  * .mpeg4 (MP4)
  * .aac (AAC)
  * .ics (Calendar)
  * .bin (Binary)
  * .mpg (MPEG)
  * .mpeg (MPEG)
  * .tar (TAR)
  * .gz (GZIP)
  * .tif (TIFF)
  * .tiff (TIFF)
  * .mov (MOV)
  • Loading branch information
SergioBenitez committed Sep 19, 2018
1 parent 95cbc24 commit 1a3fd1d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
25 changes: 24 additions & 1 deletion core/http/src/known_media_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ macro_rules! known_media_types {
SVG (is_svg): "SVG", "image", "svg+xml",
Icon (is_icon): "Icon", "image", "x-icon",
WEBM (is_webm): "WEBM", "video", "webm",
OGG (is_ogg): "OGG", "video", "ogg",
WEBA (is_weba): "WEBM Audio", "audio", "webm",
OGG (is_ogg): "OGG Video", "video", "ogg",
FLAC (is_flac): "FLAC", "audio", "flac",
WAV (is_wav): "WAV", "audio", "wav",
PDF (is_pdf): "PDF", "application", "pdf",
Expand All @@ -30,6 +31,14 @@ macro_rules! known_media_types {
WOFF2 (is_woff2): "WOFF2", "font", "woff2",
JsonApi (is_json_api): "JSON API", "application", "vnd.api+json",
WASM (is_wasm): "WASM", "application", "wasm",
TIFF (is_tiff): "TIFF", "image", "tiff",
AAC (is_aac): "AAC Audio", "audio", "aac",
Calendar (is_ical): "iCalendar", "text", "calendar",
MPEG (is_mpeg): "MPEG Video", "video", "mpeg",
TAR (is_tar): "tape archive", "application", "x-tar",
GZIP (is_gzip): "gzipped binary", "application", "gzip",
MOV (is_mov): "quicktime video", "video", "quicktime",
MP4 (is_mp4): "MPEG4 Video", "video", "mp4",
})
}

Expand All @@ -54,13 +63,27 @@ macro_rules! known_extensions {
"flac" => FLAC,
"wav" => WAV,
"webm" => WEBM,
"weba" => WEBA,
"ogg" => OGG,
"ogv" => OGG,
"pdf" => PDF,
"ttf" => TTF,
"otf" => OTF,
"woff" => WOFF,
"woff2" => WOFF2,
"mp4" => MP4,
"mpeg4" => MP4,
"wasm" => WASM,
"aac" => AAC,
"ics" => Calendar,
"bin" => Binary,
"mpg" => MPEG,
"mpeg" => MPEG,
"tar" => TAR,
"gz" => GZIP,
"tif" => TIFF,
"tiff" => TIFF,
"mov" => MOV,
})
}

Expand Down
2 changes: 1 addition & 1 deletion core/http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![feature(proc_macro_non_items)]
#![feature(try_from)]
#![feature(crate_visibility_modifier)]
#![recursion_limit="256"]
#![recursion_limit="512"]

//! Types that map to concepts in HTTP.
//!
Expand Down
10 changes: 5 additions & 5 deletions core/http/src/uri/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ use uri::{Origin, Authority, Absolute, Error};
///
/// Nevertheless, the `Uri` type is typically enountered as a conversion target.
/// In particular, you will likely see generic bounds of the form: `T:
/// TryInto<Uri>` (for instance, in [`Redirect`](rocket::Redirect) methods).
/// This means that you can provide any type `T` that implements `TryInto<Uri>`,
/// or, equivalently, any type `U` for which `Uri` implements `TryFrom<U>` or
/// `From<U>`. These include `&str` and `String`, [`Origin`], [`Authority`], and
/// [`Absolute`].
/// TryInto<Uri>` (for instance, in [`Redirect`](rocket::response::Redirect)
/// methods). This means that you can provide any type `T` that implements
/// `TryInto<Uri>`, or, equivalently, any type `U` for which `Uri` implements
/// `TryFrom<U>` or `From<U>`. These include `&str` and `String`, [`Origin`],
/// [`Authority`], and [`Absolute`].
///
/// ## Parsing
///
Expand Down

0 comments on commit 1a3fd1d

Please sign in to comment.