mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Fix stuff in fetch crate
This commit is contained in:
parent
e678943939
commit
7a2627f795
2 changed files with 19 additions and 18 deletions
|
@ -32,25 +32,24 @@ pub enum Referer {
|
||||||
|
|
||||||
/// A [request mode](http://fetch.spec.whatwg.org/#concept-request-mode)
|
/// A [request mode](http://fetch.spec.whatwg.org/#concept-request-mode)
|
||||||
pub enum RequestMode {
|
pub enum RequestMode {
|
||||||
SameOrigin, // same-origin
|
SameOrigin,
|
||||||
NoCORS, // No CORS
|
NoCORS,
|
||||||
CORSMode, // CORS
|
CORSMode,
|
||||||
ForcedPreflightMode // CORS-with-forced-preflight
|
ForcedPreflightMode
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Request [credentials mode](http://fetch.spec.whatwg.org/#concept-request-credentials-mode)
|
/// Request [credentials mode](http://fetch.spec.whatwg.org/#concept-request-credentials-mode)
|
||||||
pub enum CredentialsMode {
|
pub enum CredentialsMode {
|
||||||
Omit, // omit
|
Omit,
|
||||||
CredentialsSameOrigin, // same-origin
|
CredentialsSameOrigin,
|
||||||
Include // include
|
Include
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [Response tainting](http://fetch.spec.whatwg.org/#concept-request-response-tainting)
|
||||||
// [Response tainting](http://fetch.spec.whatwg.org/#concept-request-response-tainting)
|
|
||||||
pub enum ResponseTainting {
|
pub enum ResponseTainting {
|
||||||
Basic, // basic
|
Basic,
|
||||||
CORSTainting, // CORS
|
CORSTainting,
|
||||||
Opaque // Opaque
|
Opaque
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A [Request](http://fetch.spec.whatwg.org/#requests) as defined by the Fetch spec
|
/// A [Request](http://fetch.spec.whatwg.org/#requests) as defined by the Fetch spec
|
||||||
|
@ -104,6 +103,6 @@ impl Request {
|
||||||
manual_redirect: false,
|
manual_redirect: false,
|
||||||
redirect_count: 0,
|
redirect_count: 0,
|
||||||
response_tainting: Basic
|
response_tainting: Basic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ use http::headers::response::HeaderCollection;
|
||||||
use std::ascii::OwnedStrAsciiExt;
|
use std::ascii::OwnedStrAsciiExt;
|
||||||
|
|
||||||
// [Response type](http://fetch.spec.whatwg.org/#concept-response-type)
|
// [Response type](http://fetch.spec.whatwg.org/#concept-response-type)
|
||||||
#[deriving(Clone)]
|
#[deriving(Clone, PartialEq)]
|
||||||
pub enum ResponseType {
|
pub enum ResponseType {
|
||||||
Basic,
|
Basic,
|
||||||
CORS,
|
CORS,
|
||||||
|
@ -37,7 +37,7 @@ pub struct Response {
|
||||||
pub headers: HeaderCollection,
|
pub headers: HeaderCollection,
|
||||||
pub body: Option<Vec<u8>>,
|
pub body: Option<Vec<u8>>,
|
||||||
/// [Internal response](http://fetch.spec.whatwg.org/#concept-internal-response), only used if the Response is a filtered response
|
/// [Internal response](http://fetch.spec.whatwg.org/#concept-internal-response), only used if the Response is a filtered response
|
||||||
pub internal_response: Option<Box<Response>>,
|
pub internal_response: Option<Box<Response>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Response {
|
impl Response {
|
||||||
|
@ -60,9 +60,11 @@ impl Response {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert to a filtered response, of type `filter_type`
|
/// Convert to a filtered response, of type `filter_type`.
|
||||||
/// Do not use with type Error or Default
|
/// Do not use with type Error or Default
|
||||||
pub fn to_filtered(self, filter_type: ResponseType) -> Response {
|
pub fn to_filtered(self, filter_type: ResponseType) -> Response {
|
||||||
|
assert!(filter_type != Error);
|
||||||
|
assert!(filter_type != Default);
|
||||||
if self.is_network_error() {
|
if self.is_network_error() {
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -103,4 +105,4 @@ impl Response {
|
||||||
}
|
}
|
||||||
response
|
response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue