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

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))
}
}