aboutsummaryrefslogtreecommitdiffstats
path: root/components/net/fetch/methods.rs
diff options
context:
space:
mode:
authorPatrick Shaughnessy <pshaughn@comcast.net>2019-12-10 15:39:40 -0500
committerPatrick Shaughnessy <pshaughn@comcast.net>2019-12-16 09:07:02 -0500
commit67827debd85c7076c05277e976732593f9fa043e (patch)
tree2d01336c3bfd58f264e38fbd6e2d0f53412a1d4b /components/net/fetch/methods.rs
parentb7aaff499501e0f1f0d411db5059f59e4828419d (diff)
downloadservo-67827debd85c7076c05277e976732593f9fa043e.tar.gz
servo-67827debd85c7076c05277e976732593f9fa043e.zip
Now just one is_cors_safelisted_request_header, with closer spec alignment
Diffstat (limited to 'components/net/fetch/methods.rs')
-rw-r--r--components/net/fetch/methods.rs31
1 files changed, 4 insertions, 27 deletions
diff --git a/components/net/fetch/methods.rs b/components/net/fetch/methods.rs
index a92b0ffe2bb..9fca70fae0b 100644
--- a/components/net/fetch/methods.rs
+++ b/components/net/fetch/methods.rs
@@ -12,15 +12,17 @@ use content_security_policy as csp;
use crossbeam_channel::{unbounded, Receiver, Sender};
use devtools_traits::DevtoolsControlMsg;
use headers::{AccessControlExposeHeaders, ContentType, HeaderMapExt, Range};
-use http::header::{self, HeaderMap, HeaderName, HeaderValue};
+use http::header::{self, HeaderMap, HeaderName};
use hyper::Method;
use hyper::StatusCode;
use ipc_channel::ipc::IpcReceiver;
use mime::{self, Mime};
use net_traits::blob_url_store::{parse_blob_url, BlobURLStoreError};
use net_traits::filemanager_thread::RelativePos;
+use net_traits::request::{
+ is_cors_safelisted_method, is_cors_safelisted_request_header, Origin, ResponseTainting, Window,
+};
use net_traits::request::{CredentialsMode, Destination, Referrer, Request, RequestMode};
-use net_traits::request::{Origin, ResponseTainting, Window};
use net_traits::response::{Response, ResponseBody, ResponseType};
use net_traits::{FetchTaskTarget, NetworkError, ReferrerPolicy, ResourceFetchTiming};
use net_traits::{ResourceAttribute, ResourceTimeValue};
@@ -793,31 +795,6 @@ fn scheme_fetch(
}
}
-/// <https://fetch.spec.whatwg.org/#cors-safelisted-request-header>
-pub fn is_cors_safelisted_request_header(name: &HeaderName, value: &HeaderValue) -> bool {
- if name == header::CONTENT_TYPE {
- if let Some(m) = value.to_str().ok().and_then(|s| s.parse::<Mime>().ok()) {
- m.type_() == mime::TEXT && m.subtype() == mime::PLAIN ||
- m.type_() == mime::APPLICATION && m.subtype() == mime::WWW_FORM_URLENCODED ||
- m.type_() == mime::MULTIPART && m.subtype() == mime::FORM_DATA
- } else {
- false
- }
- } else {
- name == header::ACCEPT ||
- name == header::ACCEPT_LANGUAGE ||
- name == header::CONTENT_LANGUAGE
- }
-}
-
-/// <https://fetch.spec.whatwg.org/#cors-safelisted-method>
-pub fn is_cors_safelisted_method(m: &Method) -> bool {
- match *m {
- Method::GET | Method::HEAD | Method::POST => true,
- _ => false,
- }
-}
-
fn is_null_body_status(status: &Option<(StatusCode, String)>) -> bool {
match *status {
Some((status, _)) => match status {