mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Auto merge of #25876 - CYBAI:mime-essence, r=Manishearth
Upgrade mime crate to use the essence function While implementing module script, the `essence` function is not supported in mime crate yet so Manish filed the issue. So, as that issue is fixed and shipped, we can upgrade mime crate to use the `essence_str` function. I've tried to run https://threejs.org/examples/webgl_animation_cloth.html locally. Other than a bunch of `Unimplemented canvas2d.fillText`, I can see the animated cloth. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
commit
19a8c917f5
2 changed files with 16 additions and 12 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -3465,12 +3465,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mime"
|
name = "mime"
|
||||||
version = "0.3.13"
|
version = "0.3.16"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3e27ca21f40a310bd06d9031785f4801710d566c184a6e15bad4f1d9b65f9425"
|
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
|
||||||
dependencies = [
|
|
||||||
"unicase",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mime_guess"
|
name = "mime_guess"
|
||||||
|
|
|
@ -56,6 +56,7 @@ use js::rust::wrappers::JS_SetPendingException;
|
||||||
use js::rust::CompileOptionsWrapper;
|
use js::rust::CompileOptionsWrapper;
|
||||||
use js::rust::IntoHandle;
|
use js::rust::IntoHandle;
|
||||||
use js::rust::{Handle, HandleValue};
|
use js::rust::{Handle, HandleValue};
|
||||||
|
use mime::Mime;
|
||||||
use net_traits::request::{CredentialsMode, Destination, ParserMetadata};
|
use net_traits::request::{CredentialsMode, Destination, ParserMetadata};
|
||||||
use net_traits::request::{Referrer, RequestBuilder, RequestMode};
|
use net_traits::request::{Referrer, RequestBuilder, RequestMode};
|
||||||
use net_traits::{FetchMetadata, Metadata};
|
use net_traits::{FetchMetadata, Metadata};
|
||||||
|
@ -68,6 +69,7 @@ use std::ffi;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
use std::str::FromStr;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use url::ParseError as UrlParseError;
|
use url::ParseError as UrlParseError;
|
||||||
|
|
||||||
|
@ -934,15 +936,20 @@ impl FetchResponseListener for ModuleContext {
|
||||||
let meta = self.metadata.take().unwrap();
|
let meta = self.metadata.take().unwrap();
|
||||||
|
|
||||||
if let Some(content_type) = meta.content_type.map(Serde::into_inner) {
|
if let Some(content_type) = meta.content_type.map(Serde::into_inner) {
|
||||||
let c = content_type.to_string();
|
if let Ok(content_type) = Mime::from_str(&content_type.to_string()) {
|
||||||
// The MIME crate includes params (e.g. charset=utf8) in the to_string
|
let essence_mime = content_type.essence_str();
|
||||||
// https://github.com/hyperium/mime/issues/120
|
|
||||||
if let Some(ty) = c.split(';').next() {
|
if !SCRIPT_JS_MIMES.contains(&essence_mime) {
|
||||||
if !SCRIPT_JS_MIMES.contains(&ty) {
|
return Err(NetworkError::Internal(format!(
|
||||||
return Err(NetworkError::Internal(format!("Invalid MIME type: {}", ty)));
|
"Invalid MIME type: {}",
|
||||||
|
essence_mime
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Err(NetworkError::Internal("Empty MIME type".into()));
|
return Err(NetworkError::Internal(format!(
|
||||||
|
"Failed to parse MIME type: {}",
|
||||||
|
content_type.to_string()
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Err(NetworkError::Internal("No MIME type".into()));
|
return Err(NetworkError::Internal("No MIME type".into()));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue