summaryrefslogtreecommitdiff
path: root/fetch.go
diff options
context:
space:
mode:
authorPhilipp Tanlak <philipp.tanlak@gmail.com>2023-09-18 21:22:57 +0200
committerPhilipp Tanlak <philipp.tanlak@gmail.com>2023-09-18 21:22:57 +0200
commit49bde10c0b4d1c296960fbe94e30672da42df0e5 (patch)
treeef866172a0f6d27b973e4bdf8f891004a956e93f /fetch.go
parentc0ef0e7b99382164964be5404e76c759229c1268 (diff)
set default user-agent to flyscrape/0.1
Diffstat (limited to 'fetch.go')
-rw-r--r--fetch.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/fetch.go b/fetch.go
index f9d49d7..d969a74 100644
--- a/fetch.go
+++ b/fetch.go
@@ -13,6 +13,8 @@ import (
"github.com/cornelk/hashmap"
)
+const userAgent = "flyscrape/0.1"
+
func ProxiedFetch(proxyURL string) FetchFunc {
pu, err := url.Parse(proxyURL)
if err != nil {
@@ -63,7 +65,14 @@ func CachedFetch(fetch FetchFunc) FetchFunc {
func Fetch() FetchFunc {
return func(url string) (string, error) {
- resp, err := http.Get(url)
+ req, err := http.NewRequest(http.MethodGet, url, nil)
+ if err != nil {
+ return "", err
+ }
+
+ req.Header.Set("User-Agent", userAgent)
+
+ resp, err := http.DefaultClient.Do(req)
if err != nil {
return "", err
}