fix NewBaseline panic

This commit is contained in:
M09Ic committed 2024-06-04 16:24:36 +08:00
1 parent a97906b0b6
commit 9274cc8d29
2 files changed
+8 -1

No files matched your search

+6 -1
View File
@@ -50,7 +50,12 @@ func NewBaseline(u, host string, resp *ihttp.Response) *Baseline {
bl.Raw = append(bl.Header, bl.Body...)
bl.Response, err = ParseRawResponse(bl.Raw)
if err != nil {
bl.IsValid = false
bl.Reason = ErrResponseError.Error()
bl.ErrString = err.Error()
return bl
}
if r := bl.Response.Header.Get("Location"); r != "" {
bl.RedirectURL = r
} else {
+2
View File
@@ -16,6 +16,7 @@ const (
ErrFuzzyRedirect
ErrFuzzyNotUnique
ErrUrlError
ErrResponseError
)
var ErrMap = map[ErrorType]string{
@@ -32,6 +33,7 @@ var ErrMap = map[ErrorType]string{
ErrFuzzyRedirect: "fuzzy redirect",
ErrFuzzyNotUnique: "not unique",
ErrUrlError: "url parse error",
ErrResponseError: "response parse error",
}
func (e ErrorType) Error() string {