feat: 处理状态码

This commit is contained in:
xream 2024-12-12 15:35:19 +08:00
parent d015c7867e
commit 9a3cd4f57c
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
2 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.14.438",
"version": "2.14.439",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {

View File

@ -172,7 +172,7 @@ export default async function download(
`Downloading...\nUser-Agent: ${userAgent}\nTimeout: ${requestTimeout}\nProxy: ${proxy}\nInsecure: ${!!insecure}\nURL: ${url}`,
);
try {
const { body, headers } = await http.get({
const { body, headers, statusCode } = await http.get({
url,
...(proxy ? { proxy } : {}),
...(isLoon && proxy ? { node: proxy } : {}),
@ -180,6 +180,10 @@ export default async function download(
...(proxy ? getPolicyDescriptor(proxy) : {}),
...(insecure ? insecure : {}),
});
$.info(`statusCode: ${statusCode}`);
if (statusCode < 200 || statusCode >= 400) {
throw new Error(`statusCode: ${statusCode}`);
}
if (headers) {
const flowInfo = getFlowField(headers);