mirror of
https://github.com/servo/servo.git
synced 2025-07-26 00:30:22 +01:00
Update read blob url in chunk changes to use new hyper
This commit is contained in:
parent
2f3affcfc8
commit
67722d1943
1 changed files with 25 additions and 17 deletions
|
@ -5,11 +5,13 @@
|
||||||
use embedder_traits::{EmbedderMsg, EmbedderProxy, FilterPattern};
|
use embedder_traits::{EmbedderMsg, EmbedderProxy, FilterPattern};
|
||||||
use ipc_channel::ipc::{self, IpcSender};
|
use ipc_channel::ipc::{self, IpcSender};
|
||||||
use fetch::methods::Data;
|
use fetch::methods::Data;
|
||||||
use hyper::header::{Charset, ContentLength, ContentType, Headers};
|
use headers_core::HeaderMapExt;
|
||||||
use hyper::header::{ContentDisposition, DispositionParam, DispositionType};
|
use headers_ext::{ContentLength, ContentType};
|
||||||
use mime::{Attr, Mime};
|
use http::HeaderMap;
|
||||||
|
use http::header::{self, HeaderValue};
|
||||||
|
use mime::{self, Mime};
|
||||||
use mime_guess::guess_mime_type_opt;
|
use mime_guess::guess_mime_type_opt;
|
||||||
use net_traits::NetworkError;
|
use net_traits::{http_percent_encode, NetworkError};
|
||||||
use net_traits::blob_url_store::{BlobBuf, BlobURLStoreError};
|
use net_traits::blob_url_store::{BlobBuf, BlobURLStoreError};
|
||||||
use net_traits::filemanager_thread::{FileManagerResult, FileManagerThreadMsg, FileOrigin};
|
use net_traits::filemanager_thread::{FileManagerResult, FileManagerThreadMsg, FileOrigin};
|
||||||
use net_traits::filemanager_thread::{
|
use net_traits::filemanager_thread::{
|
||||||
|
@ -524,23 +526,29 @@ impl FileManagerStore {
|
||||||
bytes: buf.bytes.index(range).to_vec(),
|
bytes: buf.bytes.index(range).to_vec(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let content_type: Mime = blob_buf.type_string.parse().unwrap_or(mime!(Text / Plain));
|
let content_type: Mime = blob_buf.type_string.parse().unwrap_or(mime::TEXT_PLAIN);
|
||||||
let charset = content_type.get_param(Attr::Charset);
|
let charset = content_type.get_param(mime::CHARSET);
|
||||||
let mut headers = Headers::new();
|
let mut headers = HeaderMap::new();
|
||||||
|
|
||||||
if let Some(name) = blob_buf.filename {
|
if let Some(name) = blob_buf.filename {
|
||||||
let charset = charset.and_then(|c| c.as_str().parse().ok());
|
let charset = charset.map(|c| c.as_ref().into()).unwrap_or("us-ascii".to_owned());
|
||||||
headers.set(ContentDisposition {
|
// TODO(eijebong): Replace this once the typed header is there
|
||||||
disposition: DispositionType::Inline,
|
headers.insert(
|
||||||
parameters: vec![
|
header::CONTENT_DISPOSITION,
|
||||||
DispositionParam::Filename(charset.unwrap_or(Charset::Us_Ascii),
|
HeaderValue::from_bytes(
|
||||||
None, name.as_bytes().to_vec())
|
format!("inline; {}",
|
||||||
]
|
if charset.to_lowercase() == "utf-8" {
|
||||||
});
|
format!("filename=\"{}\"", String::from_utf8(name.as_bytes().into()).unwrap())
|
||||||
|
} else {
|
||||||
|
format!("filename*=\"{}\"''{}", charset, http_percent_encode(name.as_bytes()))
|
||||||
|
}
|
||||||
|
).as_bytes()
|
||||||
|
).unwrap()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
headers.set(ContentLength(blob_buf.size as u64));
|
headers.typed_insert(ContentLength(blob_buf.size as u64));
|
||||||
headers.set(ContentType(content_type.clone()));
|
headers.typed_insert(ContentType::from(content_type.clone()));
|
||||||
|
|
||||||
bytes.extend_from_slice(&blob_buf.bytes);
|
bytes.extend_from_slice(&blob_buf.bytes);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue