From f745eb578a20b438c53e5b8be1d323f4a9f364fb Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 18 Jan 2018 23:31:14 +0100 Subject: [PATCH] Check HTTP error codes --- dnscrypt-proxy/sources.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dnscrypt-proxy/sources.go b/dnscrypt-proxy/sources.go index fdae9db0..f249f935 100644 --- a/dnscrypt-proxy/sources.go +++ b/dnscrypt-proxy/sources.go @@ -62,6 +62,9 @@ func fetchWithCache(url string, cacheFile string, refreshDelay time.Duration) (i var resp *http.Response dlog.Infof("Loading source information from URL [%s]", url) resp, err = http.Get(url) + if resp.StatusCode < 200 || resp.StatusCode > 299 { + err = fmt.Errorf("Webserver returned code %d", resp.StatusCode) + } if err != nil { delayTillNextUpdate = SourcesUpdateDelayAfterFailure if usableCache { @@ -85,6 +88,7 @@ func fetchWithCache(url string, cacheFile string, refreshDelay time.Duration) (i } } } + err = nil in = string(bin) return }