From ca14de51362dba8794fb7dfd00b1963a732c5759 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 24 Jul 2018 10:14:34 +0200 Subject: enforce 200 response --- href.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/href.go b/href.go index b6c5368..bd6a61c 100644 --- a/href.go +++ b/href.go @@ -12,6 +12,7 @@ import ( var ( errNotHTML = errors.New("not HTML") + errNotOK = errors.New("not OK") errTooBig = errors.New("content too big") errNoTitle = errors.New("no title") ) @@ -46,6 +47,10 @@ func getTitle(uri string) (string, error) { return "", errNotHTML } + if resp.StatusCode != http.StatusOK { + return "", errNotOK + } + if resp.ContentLength > maxLength { return "", errTooBig } -- cgit v1.2.3