snippetgoCritical
How to set headers in http get request?
Viewed 0 times
howheadersrequestsethttpget
Problem
I'm doing a simple http GET in Go:
But I can't found a way to customize the request header in the doc, thanks
client := &http.Client{}
req, _ := http.NewRequest("GET", url, nil)
res, _ := client.Do(req)But I can't found a way to customize the request header in the doc, thanks
Solution
The
Header field of the Request is public. You may do this :req.Header.Set("name", "value")Code Snippets
req.Header.Set("name", "value")Context
Stack Overflow Q#12864302, score: 403
Revisions (0)
No revisions yet.