This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Replace reqwest with hyper #8099
Merged
Merged
Changes from 8 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
deba819
Very primitive test of the Client API
17f45c8
[WIP] getting rid of request
b47f4c6
Add support for redirects.
twittner 7fec3ae
Remove CpuPool from `fetch::Client`.
twittner ec9d156
Adapt code to API changes and fix tests.
twittner da1794e
Use reference counter to stop background thread.
twittner dc8ed22
Fix tests.
twittner a3ef61c
Comment.
twittner 6e49a09
Change expect messages.
twittner 4e4519b
Use local test server for testing fetch client.
twittner 8bd9bd9
Ensure max_size also in BodyReader.
twittner 88cd685
Replace `Condvar` with `sync_channel`.
twittner 43539ac
Re-export `url::Url` from `fetch` crate.
twittner 065780a
Remove spaces.
twittner 208047a
Use random ports in local test server.
twittner 6acb1fc
Merge branch 'master' into replace_reqwest_with_hyper
twittner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,9 +14,11 @@ | |
// You should have received a copy of the GNU General Public License | ||
// along with Parity. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
use std::{io, thread, time}; | ||
use std::{thread, time}; | ||
use std::sync::{atomic, mpsc, Arc}; | ||
use parking_lot::Mutex; | ||
use hyper; | ||
use url::Url; | ||
|
||
use futures::{self, Future}; | ||
use fetch::{self, Fetch}; | ||
|
@@ -96,11 +98,8 @@ impl FakeFetch { | |
impl Fetch for FakeFetch { | ||
type Result = Box<Future<Item = fetch::Response, Error = fetch::Error> + Send>; | ||
|
||
fn new() -> Result<Self, fetch::Error> where Self: Sized { | ||
Ok(FakeFetch::default()) | ||
} | ||
|
||
fn fetch_with_abort(&self, url: &str, _abort: fetch::Abort) -> Self::Result { | ||
fn fetch(&self, url: &str, abort: fetch::Abort) -> Self::Result { | ||
let u = Url::parse(url).unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this may be convenient. |
||
self.requested.lock().push(url.into()); | ||
let manual = self.manual.clone(); | ||
let response = self.response.clone(); | ||
|
@@ -111,23 +110,10 @@ impl Fetch for FakeFetch { | |
// wait for manual resume | ||
let _ = rx.recv(); | ||
} | ||
|
||
let data = response.lock().take().unwrap_or(b"Some content"); | ||
let cursor = io::Cursor::new(data); | ||
tx.send(fetch::Response::from_reader(cursor)).unwrap(); | ||
tx.send(fetch::Response::new(u, hyper::Response::new().with_body(data), abort)).unwrap(); | ||
}); | ||
|
||
Box::new(rx.map_err(|_| fetch::Error::Aborted)) | ||
} | ||
|
||
fn process_and_forget<F, I, E>(&self, f: F) where | ||
F: Future<Item=I, Error=E> + Send + 'static, | ||
I: Send + 'static, | ||
E: Send + 'static, | ||
{ | ||
// Spawn the task in a separate thread. | ||
thread::spawn(|| { | ||
let _ = f.wait(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ authors = ["Parity Technologies <[email protected]>"] | |
|
||
[dependencies] | ||
futures = "0.1" | ||
futures-cpupool = "0.1" | ||
log = "0.3" | ||
mime = "0.3" | ||
mime_guess = "2.0.0-alpha.2" | ||
|
@@ -25,4 +26,6 @@ ethabi-derive = "5.0" | |
ethabi-contract = "5.0" | ||
|
||
[dev-dependencies] | ||
hyper = "0.11" | ||
parking_lot = "0.5" | ||
url = "1" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That could probably be pass-through (Since we use
BodyParser
to convert async->sync and later we useinto_response()
to convert from sync->async). To be investigated in subsequent PRs.