mirror of
https://github.com/servo/servo.git
synced 2025-06-13 02:44:29 +00:00
auto merge of #5219 : doublec/servo/view_source_protocol_and_plain_text, r=jdm
Implements view-source protocol by having a view-source handler, and modifying the content type to be text/plain if that is used. Implements text/plain handling. This allows view-source content to display as plain text. Example usage: ./mach run http://cd.pn/x.txt ./mach run view-source:http://tinyvid.tv/ This fixes issue #4181. Issue #3649 includes "support text/plain" so this possibly fixes some of that issue as well.
This commit is contained in:
commit
7bd6cb0091
5 changed files with 69 additions and 23 deletions
|
@ -83,6 +83,7 @@ use js;
|
|||
use url::Url;
|
||||
|
||||
use libc;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::any::Any;
|
||||
use std::borrow::ToOwned;
|
||||
use std::cell::{Cell, RefCell};
|
||||
|
@ -978,10 +979,18 @@ impl ScriptTask {
|
|||
headers.get().map(|&LastModified(ref tm)| dom_last_modified(tm))
|
||||
});
|
||||
|
||||
let content_type = match response.metadata.content_type {
|
||||
Some((ref t, ref st)) if t.as_slice().eq_ignore_ascii_case("text") &&
|
||||
st.as_slice().eq_ignore_ascii_case("plain") => {
|
||||
Some("text/plain".to_owned())
|
||||
}
|
||||
_ => None
|
||||
};
|
||||
|
||||
let document = Document::new(window.r(),
|
||||
Some(final_url.clone()),
|
||||
IsHTMLDocument::HTMLDocument,
|
||||
None,
|
||||
content_type,
|
||||
last_modified,
|
||||
DocumentSource::FromParser).root();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue