Skip to content

Commit

Permalink
Auto merge of #6171 - eleweek:fix-4184-ok, r=Manishearth
Browse files Browse the repository at this point in the history
I tried fixing #4184 , here is the code I have right now. 

I haven't tested it, because I don't know what is the best way to test this part of code. Would like some help with testing this. Should I write an autotest or should I just test manually?

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6171)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed May 26, 2015
2 parents 9993254 + f5a0285 commit be6c251
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions components/net/resource_task.rs
Expand Up @@ -99,8 +99,23 @@ pub fn start_sending_sniffed_opt(start_chan: LoadConsumer, mut metadata: Metadat
-> Result<ProgressSender, ()> {
if opts::get().sniff_mime_types {
// TODO: should be calculated in the resource loader, from pull requeset #4094
let nosniff = false;
let check_for_apache_bug = false;
let mut nosniff = false;
let mut check_for_apache_bug = false;

if let Some(ref headers) = metadata.headers {
if let Some(ref raw_content_type) = headers.get_raw("content-type") {
if raw_content_type.len() > 0 {
let ref last_raw_content_type = raw_content_type[raw_content_type.len() - 1];
check_for_apache_bug = last_raw_content_type == b"text/plain"
|| last_raw_content_type == b"text/plain; charset=ISO-8859-1"
|| last_raw_content_type == b"text/plain; charset=iso-8859-1"
|| last_raw_content_type == b"text/plain; charset=UTF-8";
}
}
if let Some(ref raw_content_type_options) = headers.get_raw("X-content-type-options") {
nosniff = raw_content_type_options.iter().any(|ref opt| *opt == b"nosniff");
}
}

let supplied_type = metadata.content_type.map(|ContentType(Mime(toplevel, sublevel, _))| {
(format!("{}", toplevel), format!("{}", sublevel))
Expand Down

0 comments on commit be6c251

Please sign in to comment.