translate http.go

This commit is contained in:
nytpu
2021-05-11 15:19:08 -06:00
parent 21333c6085
commit 45d04c35ac
+3 -2
View File
@@ -19,6 +19,7 @@ import (
"time"
"github.com/mmcdole/gofeed"
"golang.nytpu.com/comitium/localizations"
"golang.nytpu.com/comitium/core"
)
@@ -42,7 +43,7 @@ func fetchHTTP(remoteURL string) (*http.Response, error) {
if resp.StatusCode != 200 {
resp.Body.Close()
return nil, fmt.Errorf("Unexpected HTTP response %s", resp.Status)
return nil, fmt.Errorf(core.Localizer.Get("errors.http_bad_response", &localizations.Replacements{"status": resp.Status}))
}
return resp, nil
}
@@ -58,7 +59,7 @@ func httpFeed(data *core.FullData, remote string, title string) error {
if resp.Header.Get("Content-Type") == "text/html" {
// TODO
return fmt.Errorf("Extracting feed from HTML pages is currently unsupported.")
return fmt.Errorf(core.Localizer.Get("errors.http_no_extract"))
}
reader := io.LimitReader(resp.Body, 1073741824) // 1 GiB