Check for non-success in do
This commit is contained in:
parent
16658e845d
commit
3718689e02
6
main.go
6
main.go
|
@ -87,6 +87,9 @@ func do(req *gemini.Request, via []*gemini.Request) (*gemini.Response, *gemini.R
|
||||||
redirect.URL = target
|
redirect.URL = target
|
||||||
return do(&redirect, via)
|
return do(&redirect, via)
|
||||||
}
|
}
|
||||||
|
if resp.Status.Class() != gemini.StatusSuccess {
|
||||||
|
return resp, req, errors.New(fmt.Sprintf("%d %s", resp.Status, resp.Meta))
|
||||||
|
}
|
||||||
|
|
||||||
return resp, req, err
|
return resp, req, err
|
||||||
}
|
}
|
||||||
|
@ -112,9 +115,6 @@ func main() {
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.Status.Class() != gemini.StatusSuccess {
|
|
||||||
log.Fatalf("%d %s", resp.Status, resp.Meta)
|
|
||||||
}
|
|
||||||
if resp.Meta != "text/gemini" && !strings.HasPrefix(resp.Meta, "text/gemini;") {
|
if resp.Meta != "text/gemini" && !strings.HasPrefix(resp.Meta, "text/gemini;") {
|
||||||
log.Fatal("mime type is not text/gemini")
|
log.Fatal("mime type is not text/gemini")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue