Skip to content

Commit

Permalink
Fix download speed throttle
Browse files Browse the repository at this point in the history
  • Loading branch information
ritiek committed Apr 2, 2018
1 parent 19f80d7 commit 87984ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rafy"
version = "0.2.0"
version = "0.2.1"
authors = ["Ritiek <ritiekmalhotra123@gmail.com>"]
description = "Rust library to download YouTube content and retrieve metadata"
repository = "https://github.com/ritiek/rafy-rs"
Expand Down
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ use hyper::client::response::Response;
use hyper::Client;
use hyper::net::HttpsConnector;
use hyper_native_tls::NativeTlsClient;
use hyper::header::ContentLength;
use hyper::header::{ContentLength, Headers, ByteRangeSpec, Range};
use std::io::Read;
use std::io::prelude::*;
use std::fs::File;
Expand Down Expand Up @@ -425,7 +425,10 @@ impl Rafy {
let ssl = NativeTlsClient::new().unwrap();
let connector = HttpsConnector::new(ssl);
let client = Client::with_connector(connector);
client.get(url).send()
// Pass custom headers to fix speed throttle (issue #10)
let mut header = Headers::new();
header.set(Range::Bytes(vec![ByteRangeSpec::AllFrom(0)]));
client.get(url).headers(header).send()
}

fn parse_url(query: &str) -> HashMap<String, String> {
Expand Down

0 comments on commit 87984ad

Please sign in to comment.