mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Create HttpStatus to safely deal with HTTP responses status. (#33581)
Signed-off-by: webbeef <me@webbeef.org>
This commit is contained in:
parent
013473f1d5
commit
58f34ad7a3
30 changed files with 344 additions and 403 deletions
|
@ -16,6 +16,7 @@ use euclid::default::Size2D;
|
|||
use headers::{ContentLength, ContentRange, HeaderMapExt};
|
||||
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
|
||||
use http::header::{self, HeaderMap, HeaderValue};
|
||||
use http::StatusCode;
|
||||
use ipc_channel::ipc;
|
||||
use ipc_channel::router::ROUTER;
|
||||
use js::jsapi::JSAutoRealm;
|
||||
|
@ -2731,13 +2732,14 @@ impl FetchResponseListener for HTMLMediaElementFetchListener {
|
|||
}
|
||||
}
|
||||
|
||||
let (status_is_ok, is_seekable) = self
|
||||
.metadata
|
||||
.as_ref()
|
||||
.and_then(|m| m.status.as_ref())
|
||||
.map_or((true, false), |s| {
|
||||
(s.0 >= 200 && s.0 < 300, s.0 == 206 || s.0 == 416)
|
||||
});
|
||||
let (status_is_ok, is_seekable) = self.metadata.as_ref().map_or((true, false), |s| {
|
||||
let status = &s.status;
|
||||
(
|
||||
status.is_success(),
|
||||
*status == StatusCode::PARTIAL_CONTENT ||
|
||||
*status == StatusCode::RANGE_NOT_SATISFIABLE,
|
||||
)
|
||||
});
|
||||
|
||||
if is_seekable {
|
||||
// The server supports range requests,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue