mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Make Metadata use ContentType
This commit is contained in:
parent
fe81ce942a
commit
19ffab82f1
5 changed files with 47 additions and 18 deletions
|
@ -18,8 +18,8 @@ use net_traits::ProgressMsg::Done;
|
|||
use util::opts;
|
||||
use util::task::spawn_named;
|
||||
|
||||
use hyper::header::UserAgent;
|
||||
use hyper::header::{Header, SetCookie};
|
||||
use hyper::header::{ContentType, Header, SetCookie, UserAgent};
|
||||
use hyper::mime::{Mime, TopLevel, SubLevel};
|
||||
|
||||
use std::borrow::ToOwned;
|
||||
use std::boxed;
|
||||
|
@ -27,6 +27,7 @@ use std::collections::HashMap;
|
|||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::{BufReader, Read};
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||
use std::thunk::Invoke;
|
||||
|
@ -78,8 +79,33 @@ pub fn start_sending_sniffed_opt(start_chan: Sender<LoadResponse>, mut metadata:
|
|||
let nosniff = false;
|
||||
let check_for_apache_bug = false;
|
||||
|
||||
metadata.content_type = classifier.classify(nosniff, check_for_apache_bug,
|
||||
&metadata.content_type, &partial_body);
|
||||
metadata.content_type = match metadata.content_type {
|
||||
Some(ContentType(Mime(toplevel, sublevel, _))) => {
|
||||
let content_type = classifier.classify(nosniff, check_for_apache_bug,
|
||||
&Some((format!("{}", toplevel), format!("{}", sublevel))), &partial_body);
|
||||
match content_type {
|
||||
Some((tp, sb)) => {
|
||||
let mime_tp: TopLevel = FromStr::from_str(&tp).unwrap();
|
||||
let mime_sb: SubLevel = FromStr::from_str(&sb).unwrap();
|
||||
Some(ContentType(Mime(mime_tp, mime_sb, vec!())))
|
||||
}
|
||||
None => None
|
||||
}
|
||||
}
|
||||
None => {
|
||||
let content_type = classifier.classify(nosniff, check_for_apache_bug,
|
||||
&None, &partial_body);
|
||||
|
||||
match content_type {
|
||||
Some((tp, sb)) => {
|
||||
let mime_tp: TopLevel = FromStr::from_str(&tp).unwrap();
|
||||
let mime_sb: SubLevel = FromStr::from_str(&sb).unwrap();
|
||||
Some(ContentType(Mime(mime_tp, mime_sb, vec!())))
|
||||
}
|
||||
None => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue