Skip to content

Instantly share code, notes, and snippets.

@juacompe
Created December 10, 2018 11:56
Show Gist options
  • Save juacompe/3ff9cc60f5ed109541089be8a49265a1 to your computer and use it in GitHub Desktop.
Save juacompe/3ff9cc60f5ed109541089be8a49265a1 to your computer and use it in GitHub Desktop.
func main() {
url := "https://jsonplaceholder.typicode.com/posts/1"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("cache-control", "no-cache")
for i := 0; i < 2; i++ {
tr := &http.Transport{}
http.DefaultClient.Transport = tr
res, _ := http.DefaultClient.Do(req)
b, _ := httputil.DumpResponse(res, true)
fmt.Println(string(b))
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment