pub fn calculate_ranges(req: &HttpRequest, length: u64) -> (u64, u64) {
	if let Some(ranges) = req.headers().get(header::RANGE) {
		if let Ok(rangesheader) = ranges.to_str() {
			if let Ok(rangesvec) = HttpRange::parse(rangesheader, length) {
				return (rangesvec[0].length, rangesvec[0].start)
			} else {
				return (length, 0);
			};
		} else {
			return (length, 0);
		};
	};
	(length, 0)
}
// The below code is copied from actix-files, with minor modifications. Actix Copyright (c) 2017 Nikolay Kim
The below code is copied from actix-files, with minor modifications. Actix Copyright (c) 2017 Nikolay Kim
The below code is copied from actix - files with minor modifications . Actix Copyright ( c ) 2017 Nikolay Kim
pub fn calculate_ranges(req: &HttpRequest, length: u64) -> (u64, u64) {
	if let Some(ranges) = req.headers().get(header::RANGE) {
		if let Ok(rangesheader) = ranges.to_str() {
			if let Ok(rangesvec) = HttpRange::parse(rangesheader, length) {
				return (rangesvec[0].length, rangesvec[0].start)
			} else {
				return (length, 0);
			};
		} else {
			return (length, 0);
		};
	};
	(length, 0)
}
pub fn calculate_ranges ( req : & HttpRequest , length : u64 ) -> ( u64 , u64 ) { if let Some ( ranges ) = req . headers ( ) . get ( header :: RANGE ) { if let Ok ( rangesheader ) = ranges . to_str ( ) { if let Ok ( rangesvec ) = HttpRange :: parse ( rangesheader , length ) { return ( rangesvec [ 0 ] . length , rangesvec [ 0 ] . start ) } else { return ( length , 0 ) ; } ; } else { return ( length , 0 ) ; } ; } ; ( length , 0 ) }
The below code is copied from actix-files, with minor modifications.
The below code is copied from actix - files with minor modifications .
req
&HttpRequest
length
u64
req
&HttpRequest
length
u64