crate rename: http-(entity|file) -> http-serve

This commit is contained in:
Scott Lamb 2018-01-23 11:08:21 -08:00
parent 10550bc35f
commit 8caa2e5d0e
6 changed files with 50 additions and 40 deletions

53
Cargo.lock generated
View File

@ -154,6 +154,15 @@ name = "dtoa"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "flate2"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
"miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "fnv"
version = "1.0.6"
@ -200,29 +209,18 @@ version = "0.3.54"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "http-entity"
name = "http-serve"
version = "0.0.1"
source = "git+https://github.com/scottlamb/http-entity#c09444ed4ce20bb22e44c0bd1dcc193f6243bd07"
dependencies = [
"futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.11.7 (registry+https://github.com/rust-lang/crates.io-index)",
"mime 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "http-file"
version = "0.0.1"
source = "git+https://github.com/scottlamb/http-entity#c09444ed4ce20bb22e44c0bd1dcc193f6243bd07"
source = "git+https://github.com/scottlamb/http-serve#da5f97acbeaec5ad8f832967590392625fea427e"
dependencies = [
"flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-cpupool 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"http-entity 0.0.1 (git+https://github.com/scottlamb/http-entity)",
"hyper 0.11.7 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"mime 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"unicase 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -406,6 +404,15 @@ dependencies = [
"unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "miniz-sys"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "mio"
version = "0.6.11"
@ -464,8 +471,7 @@ dependencies = [
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-cpupool 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"http-entity 0.0.1 (git+https://github.com/scottlamb/http-entity)",
"http-file 0.0.1 (git+https://github.com/scottlamb/http-entity)",
"http-serve 0.0.1 (git+https://github.com/scottlamb/http-serve)",
"hyper 0.11.7 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
@ -940,6 +946,11 @@ name = "smallvec"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "smallvec"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "stable_deref_trait"
version = "1.0.0"
@ -1216,6 +1227,7 @@ dependencies = [
"checksum cursive 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b0a0ddcf61a6c97f63c1b48164c314cba9ee393e3b4cc7db3e8aaba602cc8f8b"
"checksum docopt 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3b5b93718f8b3e5544fcc914c43de828ca6c6ace23e0332c6080a2977b49787a"
"checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab"
"checksum flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9fac2277e84e5e858483756647a9d0aa8d9a2b7cba517fd84325a0aaa69a0909"
"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
"checksum foreign-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e4056b9bd47f8ac5ba12be771f77a0dae796d1bbaaf5fd0b9c2d38b69b8a29d"
"checksum fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c0581a4e363262e52b87f59ee2afe3415361c6ec35e665924eb08afe8ff159"
@ -1223,8 +1235,7 @@ dependencies = [
"checksum futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "118b49cac82e04121117cbd3121ede3147e885627d82c4546b87c702debb90c1"
"checksum futures-cpupool 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e86f49cc0d92fe1b97a5980ec32d56208272cbb00f15044ea9e2799dde766fdf"
"checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb"
"checksum http-entity 0.0.1 (git+https://github.com/scottlamb/http-entity)" = "<none>"
"checksum http-file 0.0.1 (git+https://github.com/scottlamb/http-entity)" = "<none>"
"checksum http-serve 0.0.1 (git+https://github.com/scottlamb/http-serve)" = "<none>"
"checksum httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "af2f2dd97457e8fb1ae7c5a420db346af389926e36f43768b96f101546b04a07"
"checksum hyper 0.11.7 (git+https://github.com/scottlamb/hyper?branch=moonfire-on-0.11.x)" = "<none>"
"checksum hyper 0.11.7 (registry+https://github.com/rust-lang/crates.io-index)" = "4959ca95f55df4265bff2ad63066147255e6fa733682cf6d1cb5eaff6e53324b"
@ -1247,6 +1258,7 @@ dependencies = [
"checksum memmap 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "248000cb22d8164e9b9b74dcdb5bf89a15248d31517287a123367a47f7042460"
"checksum mime 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e2e00e17be181010a91dbfefb01660b17311059dc8c7f48b9017677721e732bd"
"checksum mime_guess 2.0.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)" = "27a5e6679a0614e25adc14c6434ba84e41632b765a6d9cb2031a0cca682699ae"
"checksum miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "609ce024854aeb19a0ef7567d348aaa5a746b32fb72e336df7fcc16869d7e2b4"
"checksum mio 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0e8411968194c7b139e9105bc4ae7db0bae232af087147e72f0616ebf5fdb9cb"
"checksum mio-uds 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1731a873077147b626d89cc6c2a0db6288d607496c5d10c0cfcf3adc697ec673"
"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
@ -1302,6 +1314,7 @@ dependencies = [
"checksum smallvec 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c8cbcd6df1e117c2210e13ab5109635ad68a929fcbb8964dc965b76cb5ee013"
"checksum smallvec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ee4f357e8cd37bf8822e1b964e96fd39e2cb5a0424f8aaa284ccaccc2162411c"
"checksum smallvec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "872c0ff227000041c520cca51e883b858d388ab0ecf646bab76f065cebaec025"
"checksum smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44db0ecb22921ef790d17ae13a3f6d15784183ff5f2a01aa32098c7498d2b4b9"
"checksum stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15132e0e364248108c5e2c02e3ab539be8d6f5d52a01ca9bbf27ed657316f02b"
"checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694"
"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"

View File

@ -19,8 +19,7 @@ docopt = "0.8"
futures = "0.1"
futures-cpupool = "0.1"
fnv = "1.0"
http-entity = { git = "https://github.com/scottlamb/http-entity" }
http-file = { git = "https://github.com/scottlamb/http-entity" }
http-serve = { git = "https://github.com/scottlamb/http-serve" }
hyper = "0.11.2"
lazy_static = "0.2"
libc = "0.2"

View File

@ -36,8 +36,7 @@ extern crate docopt;
extern crate futures;
extern crate futures_cpupool;
extern crate fnv;
extern crate http_entity;
extern crate http_file;
extern crate http_serve;
extern crate hyper;
#[macro_use] extern crate lazy_static;
extern crate libc;

View File

@ -83,7 +83,7 @@ use db;
use dir;
use error::Error;
use futures::stream;
use http_entity;
use http_serve;
use hyper::header;
use memmap;
use openssl::hash;
@ -1487,7 +1487,7 @@ impl FileInner {
#[derive(Clone)]
pub struct File(Arc<FileInner>);
impl http_entity::Entity for File {
impl http_serve::Entity for File {
type Chunk = slices::Chunk;
type Body = slices::Body;
@ -1532,7 +1532,7 @@ mod tests {
use hyper::header;
use openssl::hash;
use recording::{self, TIME_UNITS_PER_SEC};
use http_entity::{self, Entity};
use http_serve::{self, Entity};
use std::fs;
use std::ops::Range;
use std::path::Path;
@ -1543,7 +1543,7 @@ mod tests {
use stream::{self, Opener, Stream};
use testutil::{self, TestDb, TEST_CAMERA_ID};
fn fill_slice<E: http_entity::Entity>(slice: &mut [u8], e: &E, start: u64) {
fn fill_slice<E: http_serve::Entity>(slice: &mut [u8], e: &E, start: u64) {
let mut p = 0;
e.get_range(start .. start + slice.len() as u64)
.for_each(|chunk| {
@ -1557,7 +1557,7 @@ mod tests {
}
/// Returns the SHA-1 digest of the given `Entity`.
fn digest<E: http_entity::Entity>(e: &E) -> hash::DigestBytes {
fn digest<E: http_serve::Entity>(e: &E) -> hash::DigestBytes {
e.get_range(0 .. e.len())
.fold(hash::Hasher::new(hash::MessageDigest::sha1()).unwrap(), |mut sha1, chunk| {
let c: &[u8] = chunk.as_ref();
@ -2188,7 +2188,7 @@ mod bench {
use futures::Stream;
use futures::future;
use hyper;
use http_entity;
use http_serve;
use recording;
use reffers::ARefs;
use self::test::Bencher;
@ -2241,7 +2241,7 @@ mod bench {
type Future = future::FutureResult<Self::Response, Self::Error>;
fn call(&self, req: hyper::server::Request) -> Self::Future {
future::ok(http_entity::serve(self.0.clone(), &req))
future::ok(http_serve::serve(self.0.clone(), &req))
}
}

View File

@ -28,7 +28,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//! Tools for implementing a `http_entity::Entity` body composed from many "slices".
//! Tools for implementing a `http_serve::Entity` body composed from many "slices".
use error::Error;
use reffers::ARefs;
@ -50,7 +50,7 @@ pub trait Slice : fmt::Debug + Sized + Sync + 'static {
/// Note the starting position (and thus length) are inferred from the previous slice.
fn end(&self) -> u64;
/// Writes `r` to `out`, as in `http_entity::Entity::write_to`.
/// Writes `r` to `out`, as in `http_serve::Entity::write_to`.
/// The additional argument `ctx` is as supplied to the `Slices`.
/// The additional argument `l` is the length of this slice, as determined by the `Slices`.
fn get_range(&self, ctx: &Self::Ctx, r: Range<u64>, len: u64)
@ -112,7 +112,7 @@ impl<S> Slices<S> where S: Slice {
pub fn num(&self) -> usize { self.slices.len() }
/// Writes `range` to `out`.
/// This interface mirrors `http_entity::Entity::write_to`, with the additional `ctx` argument.
/// This interface mirrors `http_serve::Entity::write_to`, with the additional `ctx` argument.
pub fn get_range(&self, ctx: &S::Ctx, range: Range<u64>)
-> Box<Stream<Item = S::Chunk, Error = ::hyper::Error> + Send> {
if range.start > range.end || range.end > self.len {

View File

@ -38,8 +38,7 @@ use error::Error;
use futures::{future, stream};
use futures_cpupool;
use json;
use http_entity;
use http_file;
use http_serve;
use hyper::header;
use hyper::server::{self, Request, Response};
use mime;
@ -281,7 +280,7 @@ impl ServiceInner {
if ent.sha1 == sha1 {
builder.append_video_sample_entry(ent.clone());
let mp4 = builder.build(self.db.clone(), self.dir.clone())?;
return Ok(http_entity::serve(mp4, req));
return Ok(http_serve::serve(mp4, req));
}
}
self.not_found()
@ -376,7 +375,7 @@ impl ServiceInner {
};
}
let mp4 = builder.build(self.db.clone(), self.dir.clone())?;
Ok(http_entity::serve(mp4, req))
Ok(http_serve::serve(mp4, req))
}
fn static_file(&self, req: &Request) -> Result<Response<slices::Body>, Error> {
@ -385,8 +384,8 @@ impl ServiceInner {
Some(s) => s,
};
let f = fs::File::open(&s.path)?;
let e = http_file::ChunkedReadFile::new(f, Some(self.pool.clone()), s.mime.clone())?;
Ok(http_entity::serve(e, &req))
let e = http_serve::ChunkedReadFile::new(f, Some(self.pool.clone()), s.mime.clone())?;
Ok(http_serve::serve(e, &req))
}
}