'Why is response body in golang is a readCloser?
I'm wondering how http package in golang works. I can see that the body of http response is like this:
type Response struct {
StatusCode int
Header Header
Body io.ReadCloser
}
The Body is a ReadCloser. Why is that?
The main question is: Does http package read header and body at the same time and completely and then returns the Response or it just reads the Header part and when we are reading from Body we are actually reading from a connection? Is it possible that we encounter an error before we finish the whole body(e.g because connection drops)? or the body is completely received and resides in the memory when we get the response?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
