aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_task.rs
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-03-17 07:18:51 -0600
committerbors-servo <metajack+bors@gmail.com>2015-03-17 07:18:51 -0600
commit7bd6cb00911572e8733e462156122d974ff0c8a8 (patch)
tree32e277a4c129bf3375c67bf65db1488c1c3aafd8 /components/script/script_task.rs
parentb4b2c63c11a38ebda3eb3235af6ffa2413a73cf1 (diff)
parent618142fac7a580071f758333f91afc683e70f6d7 (diff)
downloadservo-7bd6cb00911572e8733e462156122d974ff0c8a8.tar.gz
servo-7bd6cb00911572e8733e462156122d974ff0c8a8.zip
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.
Diffstat (limited to 'components/script/script_task.rs')
-rw-r--r--components/script/script_task.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/components/script/script_task.rs b/components/script/script_task.rs
index 02c504804ce..3b17c49e45c 100644
--- a/components/script/script_task.rs
+++ b/components/script/script_task.rs
@@ -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();