mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Reduce duplication
This commit is contained in:
parent
19ffab82f1
commit
ce4b8a0af7
1 changed files with 8 additions and 27 deletions
|
@ -79,33 +79,14 @@ pub fn start_sending_sniffed_opt(start_chan: Sender<LoadResponse>, mut metadata:
|
||||||
let nosniff = false;
|
let nosniff = false;
|
||||||
let check_for_apache_bug = false;
|
let check_for_apache_bug = false;
|
||||||
|
|
||||||
metadata.content_type = match metadata.content_type {
|
let supplied_type = metadata.content_type.map(|ContentType(Mime(toplevel, sublevel, _))| {
|
||||||
Some(ContentType(Mime(toplevel, sublevel, _))) => {
|
(format!("{}", toplevel), format!("{}", sublevel))
|
||||||
let content_type = classifier.classify(nosniff, check_for_apache_bug,
|
});
|
||||||
&Some((format!("{}", toplevel), format!("{}", sublevel))), &partial_body);
|
metadata.content_type = classifier.classify(nosniff, check_for_apache_bug, &supplied_type, &partial_body).map(|(toplevel, sublevel)| {
|
||||||
match content_type {
|
let mime_tp: TopLevel = FromStr::from_str(&toplevel).unwrap();
|
||||||
Some((tp, sb)) => {
|
let mime_sb: SubLevel = FromStr::from_str(&sublevel).unwrap();
|
||||||
let mime_tp: TopLevel = FromStr::from_str(&tp).unwrap();
|
ContentType(Mime(mime_tp, mime_sb, vec!()))
|
||||||
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