整个的transfer.go做了很多操作 ,可以把它理解为http的内部处理或者转换操作
先看几个关键结构体的定义
transferWriter 是为了实现用户可操作填值的头信息处理的数据结构
type transferWriter struct {
Method string
Body io.Reade
BodyCloser io.Close
ResponseToHEAD bool
ContentLength int64 // -1 means unknown, 0 means exactly none
Close bool
TransferEncoding []string
Trailer Heade
IsResponse bool
}
transferReade
type transferReader struct {
// Input
Header Heade
StatusCode int
RequestMethod string
ProtoMajor int
ProtoMinor int
// Output
Body io.ReadClose
ContentLength int64
TransferEncoding []string
Close bool
Trailer Heade
}body定义
type body struct {
src io.Reade
hdr interface{} // non-nil (Response or Request) value means read traile
r *bufio.Reader // underlying wire-format reader for the traile
closing bool // is the connection to be closed after reading body?
doEarlyClose bool // whether Close should stop early
mu sync.Mutex // guards following, and calls to Read and Close
sawEOF bool
closed bool
earlyClose bool // Close called and we didn't read to the end of src
onHitEOF func() // if non-nil, func to call when EOF is Read
}原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。