range test

This commit is contained in:
Martin Algesten
2018-06-22 10:07:29 +02:00
parent 6593eb67c5
commit 293733643c
2 changed files with 21 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ mod auth;
mod body_read;
mod body_send;
mod query_string;
mod range;
mod simple;
type RequestHandler = Fn(&Request, &Url) -> Result<Stream, Error> + Send + 'static;

20
src/test/range.rs Normal file
View File

@@ -0,0 +1,20 @@
use std::io::Read;
use test;
use super::super::*;
#[test]
fn read_range() {
let resp = get("https://s3.amazonaws.com/foosrvr/bbb.mp4")
.set("Range", "bytes=1000-1999")
.call();
assert_eq!(*resp.status(), 206);
let mut reader = resp.into_reader();
let mut buf = vec![];
let len = reader.read_to_end(&mut buf).unwrap();
assert_eq!(len, 1000);
assert_eq!(
&buf[0..20],
[0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 3, 232, 0, 0, 0, 1]
)
}