go http transfer.go学习

整个的transfer.go做了很多操作 ,可以把它理解为http的内部处理或者转换操作
先看几个关键结构体的定义

transferWriter 是为了实现用户可操作填值的头信息处理的数据结构

type transferWriter struct {
    Method           string
    Body             io.Reader
    BodyCloser       io.Closer
    ResponseToHEAD   bool
    ContentLength    int64 // -1 means unknown, 0 means exactly none
    Close            bool
    TransferEncoding []string
    Trailer          Header
    IsResponse       bool
}

transferReader

type transferReader struct {
    // Input
    Header        Header
    StatusCode    int
    RequestMethod string
    ProtoMajor    int
    ProtoMinor    int
    // Output
    Body             io.ReadCloser
    ContentLength    int64
    TransferEncoding []string
    Close            bool
    Trailer          Header
}

body定义

type body struct {
    src          io.Reader
    hdr          interface{}   // non-nil (Response or Request) value means read trailer
    r            *bufio.Reader // underlying wire-format reader for the trailer
    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
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值