mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Make Response::new() an inherent method.
There is no real reason to put this in an extension trait.
This commit is contained in:
parent
5fbed88248
commit
8b629652ac
5 changed files with 16 additions and 39 deletions
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use fetch::cors_cache::{BasicCORSCache, CORSCache, CacheRequestDetails};
|
||||
use fetch::response::ResponseMethods;
|
||||
use http_loader::{NetworkHttpRequestFactory, WrappedHttpResponse};
|
||||
use http_loader::{create_http_connector, obtain_response, read_block, ReadResult};
|
||||
use hyper::client::response::Response as HyperResponse;
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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 hyper::header::Headers;
|
||||
use hyper::status::StatusCode;
|
||||
use net_traits::response::{CacheState, HttpsState, Response, ResponseBody, ResponseType};
|
||||
use std::ascii::AsciiExt;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::rc::Rc;
|
||||
use std::sync::mpsc::Receiver;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use url::Url;
|
||||
|
||||
pub trait ResponseMethods {
|
||||
fn new() -> Response;
|
||||
}
|
||||
|
||||
impl ResponseMethods for Response {
|
||||
fn new() -> Response {
|
||||
Response {
|
||||
response_type: ResponseType::Default,
|
||||
termination_reason: None,
|
||||
url: None,
|
||||
url_list: RefCell::new(Vec::new()),
|
||||
status: Some(StatusCode::Ok),
|
||||
headers: Headers::new(),
|
||||
body: Arc::new(Mutex::new(ResponseBody::Empty)),
|
||||
cache_state: CacheState::None,
|
||||
https_state: HttpsState::None,
|
||||
internal_response: None,
|
||||
return_internal: Cell::new(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -49,5 +49,4 @@ pub mod fetch {
|
|||
#![allow(dead_code, unused)] // XXXManishearth this is only temporary until the Fetch mod starts being used
|
||||
pub mod cors_cache;
|
||||
pub mod methods;
|
||||
pub mod response;
|
||||
}
|
||||
|
|
|
@ -93,6 +93,22 @@ pub struct Response {
|
|||
}
|
||||
|
||||
impl Response {
|
||||
pub fn new() -> Response {
|
||||
Response {
|
||||
response_type: ResponseType::Default,
|
||||
termination_reason: None,
|
||||
url: None,
|
||||
url_list: RefCell::new(Vec::new()),
|
||||
status: Some(StatusCode::Ok),
|
||||
headers: Headers::new(),
|
||||
body: Arc::new(Mutex::new(ResponseBody::Empty)),
|
||||
cache_state: CacheState::None,
|
||||
https_state: HttpsState::None,
|
||||
internal_response: None,
|
||||
return_internal: Cell::new(true)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn network_error() -> Response {
|
||||
Response {
|
||||
response_type: ResponseType::Error,
|
||||
|
|
|
@ -11,7 +11,6 @@ use hyper::server::{Request as HyperRequest, Response as HyperResponse};
|
|||
use hyper::status::StatusCode;
|
||||
use hyper::uri::RequestUri;
|
||||
use net::fetch::methods::{fetch, fetch_async};
|
||||
use net::fetch::response::ResponseMethods;
|
||||
use net_traits::request::{Origin, RedirectMode, Referer, Request, RequestMode};
|
||||
use net_traits::response::{CacheState, Response, ResponseBody, ResponseType};
|
||||
use net_traits::{AsyncFetchListener};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue