mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Implement the constructor for EventSource
This commit is contained in:
parent
75d35241db
commit
d99d26cf1f
4 changed files with 105 additions and 25 deletions
|
@ -70,7 +70,7 @@ pub enum CredentialsMode {
|
|||
}
|
||||
|
||||
/// [Cache mode](https://fetch.spec.whatwg.org/#concept-request-cache-mode)
|
||||
#[derive(Copy, Clone, PartialEq, HeapSizeOf)]
|
||||
#[derive(Copy, Clone, PartialEq, Serialize, Deserialize, HeapSizeOf)]
|
||||
pub enum CacheMode {
|
||||
Default,
|
||||
NoStore,
|
||||
|
@ -111,14 +111,16 @@ pub enum CorsSettings {
|
|||
UseCredentials
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
#[derive(Serialize, Deserialize, Clone, HeapSizeOf)]
|
||||
pub struct RequestInit {
|
||||
#[serde(deserialize_with = "::hyper_serde::deserialize",
|
||||
serialize_with = "::hyper_serde::serialize")]
|
||||
#[ignore_heap_size_of = "Defined in hyper"]
|
||||
pub method: Method,
|
||||
pub url: Url,
|
||||
#[serde(deserialize_with = "::hyper_serde::deserialize",
|
||||
serialize_with = "::hyper_serde::serialize")]
|
||||
#[ignore_heap_size_of = "Defined in hyper"]
|
||||
pub headers: Headers,
|
||||
pub unsafe_request: bool,
|
||||
pub body: Option<Vec<u8>>,
|
||||
|
@ -127,6 +129,7 @@ pub struct RequestInit {
|
|||
pub destination: Destination,
|
||||
pub synchronous: bool,
|
||||
pub mode: RequestMode,
|
||||
pub cache_mode: CacheMode,
|
||||
pub use_cors_preflight: bool,
|
||||
pub credentials_mode: CredentialsMode,
|
||||
pub use_url_credentials: bool,
|
||||
|
@ -152,6 +155,7 @@ impl Default for RequestInit {
|
|||
destination: Destination::None,
|
||||
synchronous: false,
|
||||
mode: RequestMode::NoCors,
|
||||
cache_mode: CacheMode::Default,
|
||||
use_cors_preflight: false,
|
||||
credentials_mode: CredentialsMode::Omit,
|
||||
use_url_credentials: false,
|
||||
|
@ -261,6 +265,7 @@ impl Request {
|
|||
req.use_cors_preflight = init.use_cors_preflight;
|
||||
req.credentials_mode = init.credentials_mode;
|
||||
req.use_url_credentials = init.use_url_credentials;
|
||||
req.cache_mode.set(init.cache_mode);
|
||||
*req.referrer.borrow_mut() = if let Some(url) = init.referrer_url {
|
||||
Referrer::ReferrerUrl(url)
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue