From 339cf9807debe2b20e8701ff3821079a8e925700 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 27 Apr 2015 18:55:21 -0700 Subject: net/http: documentation updates Fixes #10366 (how to set custom headers) Fixes #9836 (PATCH in PostForm) Fixes #9276 (generating a server-side Request for testing) Update #8991 (clarify Response.Write for now; export ReverseProxy's copy later?) Change-Id: I95a11bf3bb3eeeeb72775b6ebfbc761641addc35 Reviewed-on: https://go-review.googlesource.com/9410 Reviewed-by: David Crawshaw --- src/net/http/request.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/net/http/request.go') diff --git a/src/net/http/request.go b/src/net/http/request.go index a4e515c790..43d9de378a 100644 --- a/src/net/http/request.go +++ b/src/net/http/request.go @@ -169,8 +169,9 @@ type Request struct { // The HTTP client ignores Form and uses Body instead. Form url.Values - // PostForm contains the parsed form data from POST or PUT - // body parameters. + // PostForm contains the parsed form data from POST, PATCH, + // or PUT body parameters. + // // This field is only available after ParseForm is called. // The HTTP client ignores PostForm and uses Body instead. PostForm url.Values @@ -506,6 +507,13 @@ func ParseHTTPVersion(vers string) (major, minor int, ok bool) { // If the provided body is also an io.Closer, the returned // Request.Body is set to body and will be closed by the Client // methods Do, Post, and PostForm, and Transport.RoundTrip. +// +// NewRequest returns a Request suitable for use with Client.Do or +// Transport.RoundTrip. +// To create a request for use with testing a Server Handler use either +// ReadRequest or manually update the Request fields. See the Request +// type's documentation for the difference between inbound and outbound +// request fields. func NewRequest(method, urlStr string, body io.Reader) (*Request, error) { u, err := url.Parse(urlStr) if err != nil { @@ -605,7 +613,7 @@ func putTextprotoReader(r *textproto.Reader) { textprotoReaderPool.Put(r) } -// ReadRequest reads and parses a request from b. +// ReadRequest reads and parses an incoming request from b. func ReadRequest(b *bufio.Reader) (req *Request, err error) { tp := newTextprotoReader(b) -- cgit v1.3-6-g1900