mirror of
https://github.com/servo/servo.git
synced 2025-07-31 03:00:29 +01:00
Use spec compliant content-type extraction in more places and enable a <stylesheet>
quirk (#28321)
This changes includes two semi-related things: 1. Fixes some specification compliance issues when parsing mime types and charsets for `XMLHttpRequest`. 2. Implements a `<stylesheet>` parsing quirk involving mime types. Testing: There are tests for these changes. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
d8837e4a52
commit
6e97fc0bc4
17 changed files with 231 additions and 1148 deletions
|
@ -7,7 +7,6 @@
|
|||
use std::sync::Mutex;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
|
||||
use headers::{ContentType, HeaderMapExt};
|
||||
use http::HeaderMap;
|
||||
use hyper_serde::Serde;
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
|
@ -15,6 +14,7 @@ use serde::{Deserialize, Serialize};
|
|||
use servo_arc::Arc;
|
||||
use servo_url::ServoUrl;
|
||||
|
||||
use crate::fetch::headers::extract_mime_type_as_mime;
|
||||
use crate::http_status::HttpStatus;
|
||||
use crate::{
|
||||
FetchMetadata, FilteredMetadata, Metadata, NetworkError, ReferrerPolicy, ResourceFetchTiming,
|
||||
|
@ -300,13 +300,7 @@ impl Response {
|
|||
pub fn metadata(&self) -> Result<FetchMetadata, NetworkError> {
|
||||
fn init_metadata(response: &Response, url: &ServoUrl) -> Metadata {
|
||||
let mut metadata = Metadata::default(url.clone());
|
||||
metadata.set_content_type(
|
||||
response
|
||||
.headers
|
||||
.typed_get::<ContentType>()
|
||||
.map(|v| v.into())
|
||||
.as_ref(),
|
||||
);
|
||||
metadata.set_content_type(extract_mime_type_as_mime(&response.headers).as_ref());
|
||||
metadata.location_url.clone_from(&response.location_url);
|
||||
metadata.headers = Some(Serde(response.headers.clone()));
|
||||
metadata.status.clone_from(&response.status);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue