Skip to content

Commit

Permalink
Remove headers, use string range header
Browse files Browse the repository at this point in the history
  • Loading branch information
spl committed Apr 1, 2019
1 parent b542b0b commit b962502
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 60 deletions.
52 changes: 1 addition & 51 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ clap = "^2.29"
error-chain = "^0.12"
flate2 = "^1.0"
fs2 = "^0.4"
headers = "^0.2"
lazy_static = "^1.2"
libc = "^0.2"
tempfile = "^3.0"
Expand Down
10 changes: 3 additions & 7 deletions src/io/itarbundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Licensed under the MIT License.

use flate2::read::GzDecoder;
use reqwest::{header::HeaderMap, Client, RedirectPolicy, Response, StatusCode};
use reqwest::{header::RANGE, Client, RedirectPolicy, Response, StatusCode};
use std::collections::HashMap;
use std::ffi::{OsStr, OsString};
use std::io::{BufRead, BufReader, Cursor, Read};
Expand Down Expand Up @@ -44,12 +44,8 @@ impl RangeRead for HttpRangeReader {

fn read_range(&mut self, offset: u64, length: usize) -> Result<Response> {
let end_inclusive = offset + length as u64 - 1;

let mut headers = HeaderMap::new();
use headers::HeaderMapExt;
headers.typed_insert(headers::Range::bytes(offset..=end_inclusive).unwrap());

let res = self.client.get(&self.url).headers(headers).send()?;
let range = format!("bytes={}-{}", offset, end_inclusive);
let res = self.client.get(&self.url).header(RANGE, range).send()?;

if res.status() != StatusCode::PARTIAL_CONTENT {
return Err(Error::from(ErrorKind::UnexpectedHttpResponse(
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ extern crate app_dirs;
extern crate error_chain;
extern crate flate2;
extern crate fs2;
extern crate headers;
#[macro_use]
extern crate lazy_static;
extern crate libc;
Expand Down

0 comments on commit b962502

Please sign in to comment.