mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Update steps comment to match latest (2023-04-14) spec
This commit is contained in:
parent
445c90e5c5
commit
c4882aab7e
3 changed files with 81 additions and 97 deletions
|
@ -77,6 +77,7 @@ impl Response {
|
|||
reflect_dom_object(Box::new(Response::new_inherited(global)), global)
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#initialize-a-response
|
||||
pub fn Constructor(
|
||||
global: &GlobalScope,
|
||||
body: Option<BodyInit>,
|
||||
|
@ -98,34 +99,29 @@ impl Response {
|
|||
));
|
||||
}
|
||||
|
||||
// Step 3
|
||||
let r = Response::new(global);
|
||||
|
||||
// Step 4
|
||||
// Step 3
|
||||
*r.status.borrow_mut() = Some(StatusCode::from_u16(init.status).unwrap());
|
||||
|
||||
// Step 5
|
||||
// Step 4
|
||||
*r.raw_status.borrow_mut() = Some((init.status, init.statusText.clone().into()));
|
||||
|
||||
// Step 6
|
||||
// Step 5
|
||||
if let Some(ref headers_member) = init.headers {
|
||||
// Step 6.1
|
||||
r.Headers().empty_header_list();
|
||||
|
||||
// Step 6.2
|
||||
r.Headers().fill(Some(headers_member.clone()))?;
|
||||
}
|
||||
|
||||
// Step 7
|
||||
// Step 6
|
||||
if let Some(ref body) = body {
|
||||
// Step 7.1
|
||||
// Step 6.1
|
||||
if is_null_body_status(init.status) {
|
||||
return Err(Error::Type(
|
||||
"Body is non-null but init's status member is a null body status".to_string(),
|
||||
));
|
||||
};
|
||||
|
||||
// Step 7.3
|
||||
// Step 6.2
|
||||
let ExtractedBody {
|
||||
stream,
|
||||
total_bytes: _,
|
||||
|
@ -135,7 +131,7 @@ impl Response {
|
|||
|
||||
r.body_stream.set(Some(&*stream));
|
||||
|
||||
// Step 7.4
|
||||
// Step 6.3
|
||||
if let Some(content_type_contents) = content_type {
|
||||
if !r
|
||||
.Headers()
|
||||
|
@ -150,15 +146,6 @@ impl Response {
|
|||
};
|
||||
}
|
||||
|
||||
// Step 8
|
||||
|
||||
// Step 9
|
||||
// TODO: `entry settings object` is not implemented in Servo yet.
|
||||
|
||||
// Step 10
|
||||
// TODO: Write this step once Promises are merged in
|
||||
|
||||
// Step 11
|
||||
Ok(r)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue