update deps

I want to use hyper::server::Request::bytes_mut(), so an update is
needed. Update everything at once. Most notably, the http-serve update
starts using the http crate types for some things. (More to come.)
This commit is contained in:
Scott Lamb 2018-04-06 15:54:52 -07:00
parent f720f6acd4
commit b0071515e0
5 changed files with 510 additions and 269 deletions

734
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -17,14 +17,16 @@ bundled = ["rusqlite/bundled"]
members = ["base", "db", "ffmpeg"]
[dependencies]
bytes = "0.4.6"
byteorder = "1.0"
docopt = "0.8"
failure = "0.1.1"
futures = "0.1"
futures-cpupool = "0.1"
fnv = "1.0"
http = "0.1.5"
http-serve = { git = "https://github.com/scottlamb/http-serve" }
hyper = "0.11.16"
hyper = "0.11.25"
lazy_static = "1.0"
libc = "0.2"
log = { version = "0.4", features = ["release_max_level_info"] }

View File

@ -30,6 +30,7 @@
#![cfg_attr(all(feature="nightly", test), feature(test))]
extern crate bytes;
extern crate byteorder;
extern crate core;
extern crate docopt;
@ -37,6 +38,7 @@ extern crate futures;
extern crate futures_cpupool;
#[macro_use] extern crate failure;
extern crate fnv;
extern crate http;
extern crate http_serve;
extern crate hyper;
#[macro_use] extern crate lazy_static;

View File

@ -79,11 +79,13 @@
extern crate time;
use base::strutil;
use bytes::BytesMut;
use byteorder::{BigEndian, ByteOrder, WriteBytesExt};
use db::recording::{self, TIME_UNITS_PER_SEC};
use db::{self, dir};
use failure::Error;
use futures::stream;
use http;
use http_serve;
use hyper::header;
use memmap;
@ -1484,20 +1486,21 @@ impl http_serve::Entity for File {
type Chunk = slices::Chunk;
type Body = slices::Body;
fn add_headers(&self, hdrs: &mut header::Headers) {
let mut mime = String::with_capacity(64);
mime.push_str("video/mp4; codecs=\"");
fn add_headers(&self, hdrs: &mut http::header::HeaderMap) {
let mut mime = BytesMut::with_capacity(64);
mime.extend_from_slice(b"video/mp4; codecs=\"");
let mut first = true;
for e in &self.0.video_sample_entries {
if first {
first = false
} else {
mime.push_str(", ");
mime.extend_from_slice(b", ");
}
mime.push_str(&e.rfc6381_codec);
mime.extend_from_slice(e.rfc6381_codec.as_bytes());
}
mime.push('"');
hdrs.set(header::ContentType(mime.parse().unwrap()));
mime.extend_from_slice(b"\"");
hdrs.insert(http::header::CONTENT_TYPE,
http::header::HeaderValue::from_shared(mime.freeze()).unwrap());
}
fn last_modified(&self) -> Option<header::HttpDate> { Some(self.0.last_modified) }
fn etag(&self) -> Option<header::EntityTag> { Some(self.0.etag.clone()) }

View File

@ -40,6 +40,7 @@ use fnv::FnvHashMap;
use futures::{future, stream};
use futures_cpupool;
use json;
use http;
use http_serve;
use hyper::header::{self, Header};
use hyper::server::{self, Request, Response};
@ -184,7 +185,7 @@ impl Segments {
/// The files themselves are opened on every request so they can be changed during development.
#[derive(Debug)]
struct UiFile {
mime: mime::Mime,
mime: http::header::HeaderValue,
path: PathBuf,
}
@ -408,7 +409,9 @@ impl ServiceInner {
Some(s) => s,
};
let f = fs::File::open(&s.path)?;
let e = http_serve::ChunkedReadFile::new(f, Some(self.pool.clone()), s.mime.clone())?;
let mut hdrs = http::HeaderMap::new();
hdrs.insert(http::header::CONTENT_TYPE, s.mime.clone());
let e = http_serve::ChunkedReadFile::new(f, Some(self.pool.clone()), hdrs)?;
Ok(http_serve::serve(e, &req))
}
}
@ -472,13 +475,12 @@ impl Service {
},
};
let (p, mime) = match e.file_name().to_str() {
Some(n) if n == "index.html" => ("/".to_owned(), mime::TEXT_HTML),
Some(n) if n.ends_with(".html") => (format!("/{}", n), mime::TEXT_HTML),
Some(n) if n.ends_with(".ico") => (format!("/{}", n),
"image/vnd.microsoft.icon".parse().unwrap()),
Some(n) if n.ends_with(".js") => (format!("/{}", n), mime::TEXT_JAVASCRIPT),
Some(n) if n.ends_with(".map") => (format!("/{}", n), mime::TEXT_JAVASCRIPT),
Some(n) if n.ends_with(".png") => (format!("/{}", n), mime::IMAGE_PNG),
Some(n) if n == "index.html" => ("/".to_owned(), "text/html"),
Some(n) if n.ends_with(".html") => (format!("/{}", n), "text/html"),
Some(n) if n.ends_with(".ico") => (format!("/{}", n), "image/vnd.microsoft.icon"),
Some(n) if n.ends_with(".js") => (format!("/{}", n), "text/javascript"),
Some(n) if n.ends_with(".map") => (format!("/{}", n), "text/javascript"),
Some(n) if n.ends_with(".png") => (format!("/{}", n), "image/png"),
Some(n) => {
warn!("UI directory file {:?} has unknown extension; skipping", n);
continue;
@ -490,7 +492,7 @@ impl Service {
},
};
files.insert(p, UiFile {
mime,
mime: http::header::HeaderValue::from_static(mime),
path: e.path(),
});
}