mirror of
https://github.com/packwiz/packwiz.git
synced 2025-10-14 06:54:32 +02:00
Move to go-modrinth lib (v2 API) and always supply UA in HTTP requests
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/packwiz/packwiz/core"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -40,8 +41,7 @@ func (c *cfApiClient) makeGet(endpoint string) (*http.Response, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO: make this configurable application-wide
|
||||
req.Header.Set("User-Agent", "packwiz/packwiz client")
|
||||
req.Header.Set("User-Agent", core.UserAgent)
|
||||
req.Header.Set("Accept", "application/json")
|
||||
if cfApiKey == "" {
|
||||
cfApiKey = decodeDefaultKey()
|
||||
@@ -65,8 +65,7 @@ func (c *cfApiClient) makePost(endpoint string, body io.Reader) (*http.Response,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO: make this configurable application-wide
|
||||
req.Header.Set("User-Agent", "packwiz/packwiz client")
|
||||
req.Header.Set("User-Agent", core.UserAgent)
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
if cfApiKey == "" {
|
||||
|
Reference in New Issue
Block a user