mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-03-30 01:03:42 -04:00
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:
parent
f720f6acd4
commit
b0071515e0
734
Cargo.lock
generated
734
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -17,14 +17,16 @@ bundled = ["rusqlite/bundled"]
|
|||||||
members = ["base", "db", "ffmpeg"]
|
members = ["base", "db", "ffmpeg"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
bytes = "0.4.6"
|
||||||
byteorder = "1.0"
|
byteorder = "1.0"
|
||||||
docopt = "0.8"
|
docopt = "0.8"
|
||||||
failure = "0.1.1"
|
failure = "0.1.1"
|
||||||
futures = "0.1"
|
futures = "0.1"
|
||||||
futures-cpupool = "0.1"
|
futures-cpupool = "0.1"
|
||||||
fnv = "1.0"
|
fnv = "1.0"
|
||||||
|
http = "0.1.5"
|
||||||
http-serve = { git = "https://github.com/scottlamb/http-serve" }
|
http-serve = { git = "https://github.com/scottlamb/http-serve" }
|
||||||
hyper = "0.11.16"
|
hyper = "0.11.25"
|
||||||
lazy_static = "1.0"
|
lazy_static = "1.0"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
log = { version = "0.4", features = ["release_max_level_info"] }
|
log = { version = "0.4", features = ["release_max_level_info"] }
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#![cfg_attr(all(feature="nightly", test), feature(test))]
|
#![cfg_attr(all(feature="nightly", test), feature(test))]
|
||||||
|
|
||||||
|
extern crate bytes;
|
||||||
extern crate byteorder;
|
extern crate byteorder;
|
||||||
extern crate core;
|
extern crate core;
|
||||||
extern crate docopt;
|
extern crate docopt;
|
||||||
@ -37,6 +38,7 @@ extern crate futures;
|
|||||||
extern crate futures_cpupool;
|
extern crate futures_cpupool;
|
||||||
#[macro_use] extern crate failure;
|
#[macro_use] extern crate failure;
|
||||||
extern crate fnv;
|
extern crate fnv;
|
||||||
|
extern crate http;
|
||||||
extern crate http_serve;
|
extern crate http_serve;
|
||||||
extern crate hyper;
|
extern crate hyper;
|
||||||
#[macro_use] extern crate lazy_static;
|
#[macro_use] extern crate lazy_static;
|
||||||
|
17
src/mp4.rs
17
src/mp4.rs
@ -79,11 +79,13 @@
|
|||||||
extern crate time;
|
extern crate time;
|
||||||
|
|
||||||
use base::strutil;
|
use base::strutil;
|
||||||
|
use bytes::BytesMut;
|
||||||
use byteorder::{BigEndian, ByteOrder, WriteBytesExt};
|
use byteorder::{BigEndian, ByteOrder, WriteBytesExt};
|
||||||
use db::recording::{self, TIME_UNITS_PER_SEC};
|
use db::recording::{self, TIME_UNITS_PER_SEC};
|
||||||
use db::{self, dir};
|
use db::{self, dir};
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
use futures::stream;
|
use futures::stream;
|
||||||
|
use http;
|
||||||
use http_serve;
|
use http_serve;
|
||||||
use hyper::header;
|
use hyper::header;
|
||||||
use memmap;
|
use memmap;
|
||||||
@ -1484,20 +1486,21 @@ impl http_serve::Entity for File {
|
|||||||
type Chunk = slices::Chunk;
|
type Chunk = slices::Chunk;
|
||||||
type Body = slices::Body;
|
type Body = slices::Body;
|
||||||
|
|
||||||
fn add_headers(&self, hdrs: &mut header::Headers) {
|
fn add_headers(&self, hdrs: &mut http::header::HeaderMap) {
|
||||||
let mut mime = String::with_capacity(64);
|
let mut mime = BytesMut::with_capacity(64);
|
||||||
mime.push_str("video/mp4; codecs=\"");
|
mime.extend_from_slice(b"video/mp4; codecs=\"");
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
for e in &self.0.video_sample_entries {
|
for e in &self.0.video_sample_entries {
|
||||||
if first {
|
if first {
|
||||||
first = false
|
first = false
|
||||||
} else {
|
} 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('"');
|
mime.extend_from_slice(b"\"");
|
||||||
hdrs.set(header::ContentType(mime.parse().unwrap()));
|
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 last_modified(&self) -> Option<header::HttpDate> { Some(self.0.last_modified) }
|
||||||
fn etag(&self) -> Option<header::EntityTag> { Some(self.0.etag.clone()) }
|
fn etag(&self) -> Option<header::EntityTag> { Some(self.0.etag.clone()) }
|
||||||
|
22
src/web.rs
22
src/web.rs
@ -40,6 +40,7 @@ use fnv::FnvHashMap;
|
|||||||
use futures::{future, stream};
|
use futures::{future, stream};
|
||||||
use futures_cpupool;
|
use futures_cpupool;
|
||||||
use json;
|
use json;
|
||||||
|
use http;
|
||||||
use http_serve;
|
use http_serve;
|
||||||
use hyper::header::{self, Header};
|
use hyper::header::{self, Header};
|
||||||
use hyper::server::{self, Request, Response};
|
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.
|
/// The files themselves are opened on every request so they can be changed during development.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct UiFile {
|
struct UiFile {
|
||||||
mime: mime::Mime,
|
mime: http::header::HeaderValue,
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,7 +409,9 @@ impl ServiceInner {
|
|||||||
Some(s) => s,
|
Some(s) => s,
|
||||||
};
|
};
|
||||||
let f = fs::File::open(&s.path)?;
|
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))
|
Ok(http_serve::serve(e, &req))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -472,13 +475,12 @@ impl Service {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
let (p, mime) = match e.file_name().to_str() {
|
let (p, mime) = match e.file_name().to_str() {
|
||||||
Some(n) if n == "index.html" => ("/".to_owned(), mime::TEXT_HTML),
|
Some(n) if n == "index.html" => ("/".to_owned(), "text/html"),
|
||||||
Some(n) if n.ends_with(".html") => (format!("/{}", n), mime::TEXT_HTML),
|
Some(n) if n.ends_with(".html") => (format!("/{}", n), "text/html"),
|
||||||
Some(n) if n.ends_with(".ico") => (format!("/{}", n),
|
Some(n) if n.ends_with(".ico") => (format!("/{}", n), "image/vnd.microsoft.icon"),
|
||||||
"image/vnd.microsoft.icon".parse().unwrap()),
|
Some(n) if n.ends_with(".js") => (format!("/{}", n), "text/javascript"),
|
||||||
Some(n) if n.ends_with(".js") => (format!("/{}", n), mime::TEXT_JAVASCRIPT),
|
Some(n) if n.ends_with(".map") => (format!("/{}", n), "text/javascript"),
|
||||||
Some(n) if n.ends_with(".map") => (format!("/{}", n), mime::TEXT_JAVASCRIPT),
|
Some(n) if n.ends_with(".png") => (format!("/{}", n), "image/png"),
|
||||||
Some(n) if n.ends_with(".png") => (format!("/{}", n), mime::IMAGE_PNG),
|
|
||||||
Some(n) => {
|
Some(n) => {
|
||||||
warn!("UI directory file {:?} has unknown extension; skipping", n);
|
warn!("UI directory file {:?} has unknown extension; skipping", n);
|
||||||
continue;
|
continue;
|
||||||
@ -490,7 +492,7 @@ impl Service {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
files.insert(p, UiFile {
|
files.insert(p, UiFile {
|
||||||
mime,
|
mime: http::header::HeaderValue::from_static(mime),
|
||||||
path: e.path(),
|
path: e.path(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user