aboutsummaryrefslogtreecommitdiffhomepage
path: root/http
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2018-01-04 18:32:36 -0800
committerGravatar Frédéric Guillot <fred@miniflux.net>2018-01-04 18:41:23 -0800
commit7d278d49f1da6b8dc8b31faf46d4127db5f7f711 (patch)
treed471c1e2ef42d40f8124a314e08e7e95eb0ea77f /http
parentc57cafbef28a8a12cae02674b3c36979acb0e576 (diff)
Add content length check when refreshing feeds
Diffstat (limited to 'http')
-rw-r--r--http/client.go13
-rw-r--r--http/response.go13
2 files changed, 14 insertions, 12 deletions
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.