Created
December 10, 2018 11:56
-
-
Save juacompe/3ff9cc60f5ed109541089be8a49265a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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