feat: check online-config response status code

This commit is contained in:
ty
2024-06-12 12:52:39 +08:00
parent aa0e40155d
commit d71c5d3b86
@@ -14,6 +14,7 @@ use crate::{
};
use futures::StreamExt;
use http::StatusCode;
use http_body_util::BodyExt;
use log::{debug, error, trace, warn};
use mime::Mime;
@@ -108,6 +109,19 @@ impl OnlineConfigService {
let fetch_time = Instant::now();
// Check status=200
if rsp.status() != StatusCode::OK {
error!(
"server-loader task failed to get {}, status: {}",
self.config_url,
rsp.status()
);
return Err(io::Error::new(
io::ErrorKind::Other,
format!("status: {}", rsp.status()),
));
}
// Content-Type: application/json; charset=utf-8
// mandatory in standard SIP008
match rsp.headers().get("Content-Type") {