mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-11-06 16:14:11 +00:00
feat: check online-config response status code
This commit is contained in:
@@ -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") {
|
||||
|
||||
Reference in New Issue
Block a user