diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | crane.go | 2 | ||||
-rw-r--r-- | util.go | 4 |
3 files changed, 6 insertions, 2 deletions
@@ -33,7 +33,7 @@ Usage of ./crane: -path string Absolute or relative path to papers folder (default "./papers") -sci-hub string - Sci-Hub URL (default "https://sci-hub.se/") + Sci-Hub URL (default "https://sci-hub.hkvisa.net/") -user string Username for /admin/ endpoints (optional) -pass string @@ -610,7 +610,7 @@ func main() { var scihub string - flag.StringVar(&scihub, "sci-hub", "https://sci-hub.se/", "Sci-Hub URL") + flag.StringVar(&scihub, "sci-hub", "https://sci-hub.hkvisa.net/", "Sci-Hub URL") flag.StringVar(&papers.Path, "path", "./papers", "Absolute or relative path to papers folder") flag.StringVar(&host, "host", "127.0.0.1", "IP address to listen on") @@ -230,6 +230,7 @@ func getMetaFromDOI(client *http.Client, doi []byte) (*Meta, error) { if err != nil { return nil, err } + defer resp.Body.Close() if resp.StatusCode != http.StatusOK { return nil, fmt.Errorf("%q: failed to get metadata", u) @@ -267,6 +268,8 @@ func getPaper(client *http.Client, scihub *url.URL, resource string) (string, er if err != nil { return "", err } + defer resp.Body.Close() + doc, err := html.Parse(resp.Body) if err != nil { return "", err @@ -303,6 +306,7 @@ func getPaper(client *http.Client, scihub *url.URL, resource string) (string, er if err != nil { return "", err } + defer resp.Body.Close() if resp.Header.Get("content-type") != "application/pdf" { return "", fmt.Errorf("%q: content-type not application/pdf", refURL.String()) } |