usage and
// replace with fix from that issue.
@@ -130,12 +130,29 @@ impl AsyncResponseListener for ParserContext {
parser.pending_input.borrow_mut().push(page);
parser.parse_sync();
},
- _ => {}
+ Some(ContentType(Mime(TopLevel::Text, SubLevel::Html, _))) => {}, // Handle text/html
+ Some(ContentType(Mime(toplevel, sublevel, _))) => {
+ if toplevel.as_str() == "application" && sublevel.as_str() == "xhtml+xml" {
+ // Handle xhtml (application/xhtml+xml).
+ return;
+ }
+
+ // Show warning page for unknown mime types.
+ let page = format!("Unknown content type ({}/{}).
",
+ toplevel.as_str(), sublevel.as_str());
+ self.is_synthesized_document = true;
+ parser.pending_input.borrow_mut().push(page);
+ parser.parse_sync();
+ },
+ None => {
+ // No content-type header.
+ // Merge with #4212 when fixed.
+ }
}
}
fn data_available(&mut self, payload: Vec) {
- if !self.is_image_document {
+ if !self.is_synthesized_document {
// FIXME: use Vec (html5ever #34)
let data = UTF_8.decode(&payload, DecoderTrap::Replace).unwrap();
let parser = match self.parser.as_ref() {