aboutsummaryrefslogtreecommitdiff
path: root/internal/feed/parse.go
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2020-04-27 16:48:55 +0200
committerGitHub <noreply@github.com>2020-04-27 16:48:55 +0200
commit5d462ef47217c98b487bd6c1eaffb0630525ba92 (patch)
tree89594d1ad031b210ef6264ea8812e9021a47587e /internal/feed/parse.go
parentc2b5808ca6ba592507bf49512f8c90883f74ece0 (diff)
downloadfeed2imap-go-5d462ef47217c98b487bd6c1eaffb0630525ba92.tar.gz
feed2imap-go-5d462ef47217c98b487bd6c1eaffb0630525ba92.tar.bz2
feed2imap-go-5d462ef47217c98b487bd6c1eaffb0630525ba92.zip
Stylistic improvements
Diffstat (limited to 'internal/feed/parse.go')
-rw-r--r--internal/feed/parse.go19
1 files changed, 12 insertions, 7 deletions
diff --git a/internal/feed/parse.go b/internal/feed/parse.go
index cc55581..539cad0 100644
--- a/internal/feed/parse.go
+++ b/internal/feed/parse.go
@@ -13,10 +13,16 @@ import (
)
// share HTTP clients
-var stdHTTPClient = &http.Client{Transport: http.DefaultTransport}
-var unsafeHTTPClient *http.Client
+var (
+ stdHTTPClient *http.Client
+ unsafeHTTPClient *http.Client
+)
func init() {
+ // std
+ stdHTTPClient = &http.Client{Transport: http.DefaultTransport}
+
+ // unsafe
tlsConfig := &tls.Config{InsecureSkipVerify: true}
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.TLSClientConfig = tlsConfig
@@ -27,12 +33,11 @@ func context(timeout int) (ctxt.Context, ctxt.CancelFunc) {
return ctxt.WithTimeout(ctxt.Background(), time.Duration(timeout)*time.Second)
}
-func setHTTPClient(parser *gofeed.Parser, disableTLS bool) {
+func httpClient(disableTLS bool) *http.Client {
if disableTLS {
- parser.Client = unsafeHTTPClient
- } else {
- parser.Client = stdHTTPClient
+ return unsafeHTTPClient
}
+ return stdHTTPClient
}
func parseFeed(feed *Feed) error {
@@ -40,7 +45,7 @@ func parseFeed(feed *Feed) error {
defer cancel()
fp := gofeed.NewParser()
- setHTTPClient(fp, *feed.NoTLS)
+ fp.Client = httpClient(*feed.NoTLS)
parsedFeed, err := fp.ParseURLWithContext(feed.Url, ctx)
if err != nil {