fix: discard http unsuccessful status
This commit is contained in:
parent
1c23f81bbc
commit
e6dad8ef3e
1 changed files with 7 additions and 3 deletions
|
@ -2,12 +2,14 @@ package resource
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
clashHttp "github.com/Dreamacro/clash/component/http"
|
"errors"
|
||||||
types "github.com/Dreamacro/clash/constant/provider"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
clashHttp "github.com/Dreamacro/clash/component/http"
|
||||||
|
types "github.com/Dreamacro/clash/constant/provider"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FileVehicle struct {
|
type FileVehicle struct {
|
||||||
|
@ -54,8 +56,10 @@ func (h *HTTPVehicle) Read() ([]byte, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
if resp.StatusCode < 200 && resp.StatusCode > 299 {
|
||||||
|
return nil, errors.New(resp.Status)
|
||||||
|
}
|
||||||
buf, err := io.ReadAll(resp.Body)
|
buf, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in a new issue