Replace reqwest with hyper (#8099)

* Very primitive test of the Client API

* [WIP] getting rid of request

* Add support for redirects.

* Remove CpuPool from `fetch::Client`.

* Adapt code to API changes and fix tests.

* Use reference counter to stop background thread.

On `clone` the counter is incremented, on `drop` decremented. Once 0 we
send `None` over the channel, expecting the background thread to end.

* Fix tests.

* Comment.

* Change expect messages.

* Use local test server for testing fetch client.

* Ensure max_size also in BodyReader.

* Replace `Condvar` with `sync_channel`.

* Re-export `url::Url` from `fetch` crate.

* Remove spaces.

* Use random ports in local test server.
This commit is contained in:
Toralf Wittner
2018-03-14 13:40:54 +01:00
committed by Fredrik Harrysson
parent 1bad20ae38
commit 322dfbcd78
29 changed files with 1051 additions and 753 deletions

View File

@@ -58,6 +58,8 @@ pub struct UpdatePolicy {
pub track: ReleaseTrack,
/// Path for the updates to go.
pub path: String,
/// Maximum download size.
pub max_size: usize,
}
impl Default for UpdatePolicy {
@@ -68,6 +70,7 @@ impl Default for UpdatePolicy {
filter: UpdateFilter::None,
track: ReleaseTrack::Unknown,
path: Default::default(),
max_size: 128 * 1024 * 1024,
}
}
}
@@ -341,7 +344,8 @@ impl Updater {
drop(s);
let weak_self = self.weak_self.lock().clone();
let f = move |r: Result<PathBuf, fetch::Error>| if let Some(this) = weak_self.upgrade() { this.fetch_done(r) };
self.fetcher.fetch(b, Box::new(f));
let a = fetch::Abort::default().with_max_size(self.update_policy.max_size);
self.fetcher.fetch(b, a, Box::new(f));
}
}
}