mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
bypass SM for in-memory streams in request bodies, dis-allow other cases in sync XHR
This commit is contained in:
parent
3535dd7412
commit
ad4dea7d84
3 changed files with 75 additions and 19 deletions
|
@ -580,7 +580,13 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
|||
})
|
||||
},
|
||||
Some(DocumentOrBodyInit::Blob(ref b)) => {
|
||||
Some(b.extract(&self.global()).expect("Couldn't extract body."))
|
||||
let extracted_body = b.extract(&self.global()).expect("Couldn't extract body.");
|
||||
if !extracted_body.in_memory() && self.sync.get() {
|
||||
warn!("Sync XHR with not in-memory Blob as body not supported");
|
||||
None
|
||||
} else {
|
||||
Some(extracted_body)
|
||||
}
|
||||
},
|
||||
Some(DocumentOrBodyInit::FormData(ref formdata)) => Some(
|
||||
formdata
|
||||
|
@ -620,21 +626,23 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
|||
})
|
||||
},
|
||||
Some(DocumentOrBodyInit::ReadableStream(ref stream)) => {
|
||||
// TODO:
|
||||
// 1. If the keepalive flag is set, then throw a TypeError.
|
||||
if self.sync.get() {
|
||||
warn!("Sync XHR with ReadableStream as body not supported");
|
||||
None
|
||||
} else {
|
||||
if stream.is_locked() || stream.is_disturbed() {
|
||||
return Err(Error::Type(
|
||||
"The body's stream is disturbed or locked".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
if stream.is_locked() || stream.is_disturbed() {
|
||||
return Err(Error::Type(
|
||||
"The body's stream is disturbed or locked".to_string(),
|
||||
));
|
||||
Some(ExtractedBody {
|
||||
stream: stream.clone(),
|
||||
total_bytes: None,
|
||||
content_type: None,
|
||||
source: BodySource::Null,
|
||||
})
|
||||
}
|
||||
|
||||
Some(ExtractedBody {
|
||||
stream: stream.clone(),
|
||||
total_bytes: None,
|
||||
content_type: None,
|
||||
source: BodySource::Null,
|
||||
})
|
||||
},
|
||||
None => None,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue