feat: default http User-Agent header (#26)

This commit is contained in:
Tracey Lesley authored and GitHub committed 2023-09-13 10:03:26 +08:00
1 parent d694c08635
commit d28fcef0a7
2 files changed
+8

No files matched your search

+3
View File
@@ -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)
+5
View File
@@ -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"
)