Http Client
Advanced · Standard Library & I/O
Making HTTP requests with net/http. (Pairs with testing_advanced/testadv3,
which tests an HTTP handler.)
- http1 —
http.Get, closing the body, reading the response
Resources
Section titled “Resources”Exercises
Section titled “Exercises”http1 test
Section titled “http1 test”http1 — HTTP client
Show hint
GET, close the body, read it:
resp, err := http.Get(url); if err != nil { return "", err }defer resp.Body.Close()body, err := io.ReadAll(resp.Body); return string(body), err