Add known media types and extensions.

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)
This commit is contained in:
Sergio Benitez 2018-09-18 18:25:39 -07:00
parent 95cbc241db
commit 1a3fd1d237
3 changed files with 30 additions and 7 deletions

View File

@ -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",
@ -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",
})
}
@ -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,
})
}

View File

@ -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.
//!

View File

@ -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
///