diff --git a/internal/protocol/http/fetcher.go b/internal/protocol/http/fetcher.go index 5bbfdb10..d53d0ae6 100644 --- a/internal/protocol/http/fetcher.go +++ b/internal/protocol/http/fetcher.go @@ -428,6 +428,9 @@ func buildRequest(ctx context.Context, req *base.Request) (httpReq *http.Request body = bytes.NewBufferString(extra.Body) } } + if _, ok := headers[base.HttpHeaderUserAgent]; !ok { + headers[base.HttpHeaderUserAgent] = []string{base.AgentName} + } if ctx != nil { httpReq, err = http.NewRequestWithContext(ctx, method, url.String(), body) diff --git a/pkg/base/constants.go b/pkg/base/constants.go index 0fc711e4..73481a28 100644 --- a/pkg/base/constants.go +++ b/pkg/base/constants.go @@ -19,6 +19,11 @@ const ( HttpHeaderContentLength = "Content-Length" HttpHeaderContentRange = "Content-Range" HttpHeaderContentDisposition = "Content-Disposition" + HttpHeaderUserAgent = "User-Agent" HttpHeaderRangeFormat = "bytes=%d-%d" ) + +const ( + AgentName = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36" +)