mirror of
https://github.com/servo/servo.git
synced 2025-08-15 10:25:32 +01:00
Abstract everything but the response from hyper
Because we're using unsized types not for requesting, there's not a satisfactory way of doing this without boxing the request... Once unsized stuff lands in rust 1.2/1.3(???) then this should be implemented with Rc's instead of Box's. For the time being I'm not sure what else to do. servo/servo#6727
This commit is contained in:
parent
6cba33a50b
commit
7633cd54c2
2 changed files with 57 additions and 44 deletions
|
@ -2,24 +2,23 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use net::http_loader::{load, LoadError, HttpRequester};
|
||||
use net::http_loader::{load, LoadError, HttpRequester, HttpRequest};
|
||||
use url::Url;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use ipc_channel::ipc;
|
||||
use net_traits::LoadData;
|
||||
use net::hsts::HSTSList;
|
||||
use hyper::client::{Request, Response};
|
||||
use hyper::net::Fresh;
|
||||
use hyper::client::Response;
|
||||
use hyper::method::Method;
|
||||
|
||||
struct MockHttpRequester;
|
||||
|
||||
impl HttpRequester for MockHttpRequester {
|
||||
fn build(&self, url: Url, _: Method) -> Result<Request<Fresh>, LoadError> {
|
||||
fn build(&self, url: Url, _: Method) -> Result<Box<HttpRequest>, LoadError> {
|
||||
Err(LoadError::Connection(url.clone(), "shouldn't connect".to_string()))
|
||||
}
|
||||
|
||||
fn send(&self, _: Request<Fresh>) -> Result<Response, LoadError> {
|
||||
fn send(&self, _: Box<HttpRequest>) -> Result<Response, LoadError> {
|
||||
Err(LoadError::Connection(Url::parse("http://example.com").unwrap(), "shouldn't connect".to_string()))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue