Skip to content

Commit d0d8466

Browse files
committed
net/http, net/http/httptest: cross-reference the two NewRequest funcs
Updates #18082 Change-Id: I2e65b115b809c1e1bf813f538989d1a1f96b2876 Reviewed-on: https://go-review.googlesource.com/33636 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent f7c351b commit d0d8466

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/net/http/httptest/httptest.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ import (
3535
//
3636
// NewRequest panics on error for ease of use in testing, where a
3737
// panic is acceptable.
38+
//
39+
// To generate an client HTTP request instead of a server request, see
40+
// the NewRequest function in the net/http package.
3841
func NewRequest(method, target string, body io.Reader) *http.Request {
3942
if method == "" {
4043
method = "GET"

src/net/http/request.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -726,11 +726,11 @@ func validMethod(method string) bool {
726726
// methods Do, Post, and PostForm, and Transport.RoundTrip.
727727
//
728728
// NewRequest returns a Request suitable for use with Client.Do or
729-
// Transport.RoundTrip.
730-
// To create a request for use with testing a Server Handler use either
731-
// ReadRequest or manually update the Request fields. See the Request
732-
// type's documentation for the difference between inbound and outbound
733-
// request fields.
729+
// Transport.RoundTrip. To create a request for use with testing a
730+
// Server Handler, either use the NewRequest function in the
731+
// net/http/httptest package, use ReadRequest, or manually update the
732+
// Request fields. See the Request type's documentation for the
733+
// difference between inbound and outbound request fields.
734734
func NewRequest(method, urlStr string, body io.Reader) (*Request, error) {
735735
if method == "" {
736736
// We document that "" means "GET" for Request.Method, and people have

0 commit comments

Comments
 (0)