/// Fetches just the `isize` field (the field that indicates the uncompressed size)
/// of a gzip file from a URL. This makes two round-trips to the server but avoids
/// downloading the entire gzip file. For very small files it's unlikely to be
/// more efficient than simply downloading the entire file up front.
Fetches just the `isize` field (the field that indicates the uncompressed size)
of a gzip file from a URL. This makes two round-trips to the server but avoids
downloading the entire gzip file. For very small files it's unlikely to be
more efficient than simply downloading the entire file up front.
Fetches just the ` isize ` field ( the field that indicates the uncompressed size ) of a gzip file from a URL . This makes two round - trips to the server but avoids downloading the entire gzip file . For very small files it ' s unlikely to be more efficient than simply downloading the entire file up front .
fn fetch_isize(url: &str, len: u64) -> Result<[u8; 4], failure::Error> {
    let client = reqwest::Client::new();
    let mut response = client
        .get(url)
        .header_011(Range::Bytes(vec![ByteRangeSpec::FromTo(len - 4, len - 1)]))
        .send()?;
    if !response.status().is_success() {
        return Err(super::HttpError {
            code: response.status(),
        }
        .into());
    }
    let actual_length = content_length(&response)?;
    if actual_length != 4 {
        return Err(UnexpectedContentLengthError {
            length: actual_length,
        }
        .into());
    }
    let mut buf = [0; 4];
    response.read_exact(&mut buf)?;
    Ok(buf)
}
fn fetch_isize ( url : & str , len : u64 ) -> Result < [ u8 ; 4 ] , failure :: Error > { let client = reqwest :: Client :: new ( ) ; let mut response = client . get ( url ) . header_011 ( Range :: Bytes ( vec ! [ ByteRangeSpec FromTo ( len 4 len 1 ) ] ) ) . send ( ) ? ; if ! response . status ( ) . is_success ( ) { return Err ( super :: HttpError { code : response . status ( ) , } . into ( ) ) ; } let actual_length = content_length ( & response ) ? ; if actual_length != 4 { return Err ( UnexpectedContentLengthError { length : actual_length , } . into ( ) ) ; } let mut buf = [ 0 ; 4 ] ; response . read_exact ( & mut buf ) ? ; Ok ( buf ) }
Fetches just the `isize` field (the field that indicates the uncompressed size)
of a gzip file from a URL.
Fetches just the ` isize ` field ( the field that indicates the uncompressed size ) of a gzip file from a URL .
url
&str
len
u64