Skip to content

Latest commit

 

History

History
32 lines (29 loc) · 959 Bytes

12.1.2.md

File metadata and controls

32 lines (29 loc) · 959 Bytes

http.Request类型

http.Request类型的作用是表示HTTP请求,该类型可以用于表示服务器接收的请求,或在HTTP客户端即将发送到服务器的请求。

源代码https://golang.org/src/net/http/request.go中定义的http.Request结构类型如下:

type Request struct {
    Method string
    URL *url.URL
    Proto string // "HTTP/1.0"
    ProtoMajor int // 1
    ProtoMinor int // 0
    Header Header
    Body io.ReadCloser
    GetBody func() (io.ReadCloser, error)
    ContentLength int64
    TransferEncoding []string
    Close bool
    Host string
    Form url.Values
    PostForm url.Values
    MultipartForm *multipart.Form
    Trailer Header
    RemoteAddr string
    RequestURI string
    TLS *tls.ConnectionState
    Cancel <-chan struct{}
    Response *Response
    ctx context.Context
}