Update the steps in fetch_with_cors_cache

This commit is contained in:
Anthony Ramine 2017-04-04 12:55:59 +02:00
parent 053aaedb52
commit 4281205662

View file

@ -61,23 +61,23 @@ pub fn fetch_with_cors_cache(request: &mut Request,
cache: &mut CorsCache, cache: &mut CorsCache,
target: Target, target: Target,
context: &FetchContext) { context: &FetchContext) {
// Step 1 // Step 1.
if request.window == Window::Client { if request.window == Window::Client {
// TODO: Set window to request's client object if client is a Window object // TODO: Set window to request's client object if client is a Window object
} else { } else {
request.window = Window::NoWindow; request.window = Window::NoWindow;
} }
// Step 2 // Step 2.
if request.origin == Origin::Client { if request.origin == Origin::Client {
// TODO: set request's origin to request's client's origin // TODO: set request's origin to request's client's origin
unimplemented!() unimplemented!()
} }
// Step 3 // Step 3.
if !request.headers.has::<Accept>() { if !request.headers.has::<Accept>() {
let value = match request.type_ { let value = match request.type_ {
// Substep 2 // Step 3.2.
_ if request.is_navigation_request() => _ if request.is_navigation_request() =>
vec![qitem(mime!(Text / Html)), vec![qitem(mime!(Text / Html)),
// FIXME: This should properly generate a MimeType that has a // FIXME: This should properly generate a MimeType that has a
@ -86,7 +86,7 @@ pub fn fetch_with_cors_cache(request: &mut Request,
QualityItem::new(mime!(Application / Xml), q(0.9)), QualityItem::new(mime!(Application / Xml), q(0.9)),
QualityItem::new(mime!(_ / _), q(0.8))], QualityItem::new(mime!(_ / _), q(0.8))],
// Substep 3 // Step 3.3.
Type::Image => Type::Image =>
vec![qitem(mime!(Image / Png)), vec![qitem(mime!(Image / Png)),
// FIXME: This should properly generate a MimeType that has a // FIXME: This should properly generate a MimeType that has a
@ -95,30 +95,33 @@ pub fn fetch_with_cors_cache(request: &mut Request,
QualityItem::new(mime!(Image / _), q(0.8)), QualityItem::new(mime!(Image / _), q(0.8)),
QualityItem::new(mime!(_ / _), q(0.5))], QualityItem::new(mime!(_ / _), q(0.5))],
// Substep 3 // Step 3.3.
Type::Style => Type::Style =>
vec![qitem(mime!(Text / Css)), vec![qitem(mime!(Text / Css)),
QualityItem::new(mime!(_ / _), q(0.1))], QualityItem::new(mime!(_ / _), q(0.1))],
// Substep 1 // Step 3.1.
_ => vec![qitem(mime!(_ / _))] _ => vec![qitem(mime!(_ / _))]
}; };
// Substep 4 // Step 3.4.
request.headers.set(Accept(value)); request.headers.set(Accept(value));
} }
// Step 4 // Step 4.
set_default_accept_language(&mut request.headers); set_default_accept_language(&mut request.headers);
// Step 5 // Step 5.
// TODO: Figure out what a Priority object is // TODO: figure out what a Priority object is.
// Step 6 // Step 6.
// TODO: handle client hints headers.
// Step 7.
if request.is_subresource_request() { if request.is_subresource_request() {
// TODO: create a fetch record and append it to request's client's fetch group list // TODO: handle client hints headers.
} }
// Step 7 // Step 8.
main_fetch(request, cache, false, false, target, &mut None, &context); main_fetch(request, cache, false, false, target, &mut None, &context);
} }