Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M1456: Implement MIME Sniffing #4209

Closed
wants to merge 7 commits into from

foreward errors

  • Loading branch information
IdeaHat authored and djzager committed Dec 5, 2014
commit e161bd5ede0d51c4be0a26d42e521e7745a80ae1
@@ -45,39 +45,36 @@ impl SnifferManager {
Payload(data) => {
resource_data.push_all(data.as_slice());
}
Done(Ok(..)) => {
break;
}
Done(Err(..)) => {
break;
Done(res) => {
let (new_progress_chan, new_progress_port) = channel();

// TODO: should be calculated in the resource loader, from pull requeset #4094
let nosniff = false;
let check_for_apache_bug = false;

// We have all the data, go ahead and sniff it and replace the Content-Type
if res.is_ok() {
snif_data.load_response.metadata.content_type = self.mime_classifier.classify(
nosniff,check_for_apache_bug,&snif_data.load_response.metadata.content_type,
&resource_data
);
}
let load_response = LoadResponse {
progress_port: new_progress_port,
metadata: snif_data.load_response.metadata,
};

let result = snif_data.consumer.send_opt(load_response);
if result.is_err() {
break;
}

new_progress_chan.send(Payload(resource_data));
new_progress_chan.send(Done(res));
return;
}
}
}

let (new_progress_chan, new_progress_port) = channel();

// TODO: should be calculated in the resource loader, from pull requeset #4094
let nosniff = false;
let check_for_apache_bug = false;

// We have all the data, go ahead and sniff it and replace the Content-Type
snif_data.load_response.metadata.content_type = self.mime_classifier.classify(
nosniff,check_for_apache_bug,&snif_data.load_response.metadata.content_type,
&resource_data
);

let load_response = LoadResponse {
progress_port: new_progress_port,
metadata: snif_data.load_response.metadata,
};

let result = snif_data.consumer.send_opt(load_response);
if result.is_err() {
break;
}

new_progress_chan.send(Payload(resource_data));
new_progress_chan.send(Done(Ok(())));
}
Err(_) => break,
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.