-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Description
go version 1.11.2.
i use http.client to get an object from an object storage server continually.
the server will response with status code 307 and a redirection url.
my code like:
for ; true; {
go func() {
url := "http://storage.server.com/key/object1"
client := http.Client{
}
resp, err := client.Get(url)
if err != nil {
return
}
if resp.Body != nil {
defer resp.Body.Close()
}
// ioutil.ReadAll(resp.Body) // this special line
}()
}
if uncomment the special line it works as my expection, object will be downloaded continually and data stream could be watched from network card,
# dstat -n 1
recv send
1679M 4241k
1728M 4632k
1710M 3984k
1699M 4007k
1777M 3957k
804M 2591k
1967M 8078k
1558M 4155k
1308M 2821k
1484M 3211k
1430M 3076k
1610M 3915k
if comment the special line, the http.client will also send a request to the redirection url, but no as much as data stream be watched in network card. i doubt that the objects didn't be downloaded.
# dstat -n 1
10M 2289k
11M 2289k
12M 1797k
13M 2428k
210k 149k
9356k 2103k
12M 2361k
11M 2073k
11M 2040k
my question is what's the difference between processing http response with and without 'ioutil.ReadAll(resp.Body)'.
could anyone help me to resolve my confusion? thanks.
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.