From 7d278d49f1da6b8dc8b31faf46d4127db5f7f711 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Thu, 4 Jan 2018 18:32:36 -0800 Subject: Add content length check when refreshing feeds --- http/client.go | 13 +++++++------ http/response.go | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'http') diff --git a/http/client.go b/http/client.go index 934c7f5..cdff0ce 100644 --- a/http/client.go +++ b/http/client.go @@ -86,12 +86,13 @@ func (c *Client) executeRequest(request *http.Request) (*Response, error) { } response := &Response{ - Body: resp.Body, - StatusCode: resp.StatusCode, - EffectiveURL: resp.Request.URL.String(), - LastModified: resp.Header.Get("Last-Modified"), - ETag: resp.Header.Get("ETag"), - ContentType: resp.Header.Get("Content-Type"), + Body: resp.Body, + StatusCode: resp.StatusCode, + EffectiveURL: resp.Request.URL.String(), + LastModified: resp.Header.Get("Last-Modified"), + ETag: resp.Header.Get("ETag"), + ContentType: resp.Header.Get("Content-Type"), + ContentLength: resp.ContentLength, } logger.Debug("[HttpClient:%s] OriginalURL=%s, StatusCode=%d, ContentLength=%d, ETag=%s, LastModified=%s, EffectiveURL=%s", diff --git a/http/response.go b/http/response.go index 7213be7..d9e9db6 100644 --- a/http/response.go +++ b/http/response.go @@ -13,12 +13,13 @@ import ( // Response wraps a server response. type Response struct { - Body io.Reader - StatusCode int - EffectiveURL string - LastModified string - ETag string - ContentType string + Body io.Reader + StatusCode int + EffectiveURL string + LastModified string + ETag string + ContentType string + ContentLength int64 } // HasServerFailure returns true if the status code represents a failure. -- cgit v1.2.3