Move to go-modrinth lib (v2 API) and always supply UA in HTTP requests

This commit is contained in:
comp500
2022-08-02 02:53:31 +01:00
parent 5c02b31e20
commit 044c34e07c
10 changed files with 97 additions and 315 deletions

View File

@@ -6,7 +6,6 @@ import (
"github.com/spf13/viper"
"golang.org/x/exp/slices"
"io"
"net/http"
"path/filepath"
"regexp"
"strconv"
@@ -540,8 +539,7 @@ func (m *cfDownloadMetadata) GetManualDownload() (bool, core.ManualDownload) {
}
func (m *cfDownloadMetadata) DownloadFile() (io.ReadCloser, error) {
resp, err := http.Get(m.url)
// TODO: content type, user-agent?
resp, err := core.GetWithUA(m.url, "application/octet-stream")
if err != nil {
return nil, fmt.Errorf("failed to download %s: %w", m.url, err)
}