Skip to content

net/http: golint var and function name fixes #27974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/net/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func send(ireq *Request, rt RoundTripper, deadline time.Time) (resp *Response, d

if req.RequestURI != "" {
req.closeBody()
return nil, alwaysFalse, errors.New("http: Request.RequestURI can't be set in client requests.")
return nil, alwaysFalse, errors.New("http: Request.RequestURI can't be set in client requests")
}

// forkReq forks req into a shallow clone of ireq the first
Expand Down
2 changes: 1 addition & 1 deletion src/net/http/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1721,7 +1721,7 @@ func TestShouldCopyHeaderOnRedirect(t *testing.T) {
t.Errorf("%d. dest URL %q parse error: %v", i, tt.destURL, err)
continue
}
got := Export_shouldCopyHeaderOnRedirect(tt.header, u0, u1)
got := ExportShouldCopyHeaderOnRedirect(tt.header, u0, u1)
if got != tt.want {
t.Errorf("%d. shouldCopyHeaderOnRedirect(%q, %q => %q) = %v; want %v",
i, tt.header, tt.initialURL, tt.destURL, got, tt.want)
Expand Down
6 changes: 3 additions & 3 deletions src/net/http/clientserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ func newClientServerTest(t *testing.T, h2 bool, h Handler, opts ...interface{})
cst.ts.Start()
return cst
}
ExportHttp2ConfigureServer(cst.ts.Config, nil)
ExportHTTP2ConfigureServer(cst.ts.Config, nil)
cst.ts.TLS = cst.ts.Config.TLSConfig
cst.ts.StartTLS()

cst.tr.TLSClientConfig = &tls.Config{
InsecureSkipVerify: true,
}
if err := ExportHttp2ConfigureTransport(cst.tr); err != nil {
if err := ExportHTTP2ConfigureTransport(cst.tr); err != nil {
t.Fatal(err)
}
return cst
Expand Down Expand Up @@ -984,7 +984,7 @@ func TestTransportDiscardsUnneededConns(t *testing.T) {
return tls.Client(c, tlsConfig), nil
},
}
if err := ExportHttp2ConfigureTransport(tr); err != nil {
if err := ExportHTTP2ConfigureTransport(tr); err != nil {
t.Fatal(err)
}
defer tr.CloseIdleConnections()
Expand Down
8 changes: 4 additions & 4 deletions src/net/http/cookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Cookie struct {
// MaxAge>0 means Max-Age attribute present and given in seconds
MaxAge int
Secure bool
HttpOnly bool
HTTPOnly bool
SameSite SameSite
Raw string
Unparsed []string // Raw text of unparsed attribute-value pairs
Expand Down Expand Up @@ -113,7 +113,7 @@ func readSetCookies(h Header) []*Cookie {
c.Secure = true
continue
case "httponly":
c.HttpOnly = true
c.HTTPOnly = true
continue
case "domain":
c.Domain = val
Expand Down Expand Up @@ -204,8 +204,8 @@ func (c *Cookie) String() string {
} else if c.MaxAge < 0 {
b.WriteString("; Max-Age=0")
}
if c.HttpOnly {
b.WriteString("; HttpOnly")
if c.HTTPOnly {
b.WriteString("; HTTPOnly")
}
if c.Secure {
b.WriteString("; Secure")
Expand Down
10 changes: 5 additions & 5 deletions src/net/http/cookie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ var readSetCookiesTests = []struct {
Value: "99=YsDT5i3E-CXax-",
Path: "/",
Domain: ".google.ch",
HttpOnly: true,
HTTPOnly: true,
Expires: time.Date(2011, 11, 23, 1, 5, 3, 0, time.UTC),
RawExpires: "Wed, 23-Nov-2011 01:05:03 GMT",
Raw: "NID=99=YsDT5i3E-CXax-; expires=Wed, 23-Nov-2011 01:05:03 GMT; path=/; domain=.google.ch; HttpOnly",
Expand All @@ -239,7 +239,7 @@ var readSetCookiesTests = []struct {
Path: "/",
Expires: time.Date(2012, 3, 7, 14, 25, 6, 0, time.UTC),
RawExpires: "Wed, 07-Mar-2012 14:25:06 GMT",
HttpOnly: true,
HTTPOnly: true,
Raw: ".ASPXAUTH=7E3AA; expires=Wed, 07-Mar-2012 14:25:06 GMT; path=/; HttpOnly",
}},
},
Expand All @@ -249,7 +249,7 @@ var readSetCookiesTests = []struct {
Name: "ASP.NET_SessionId",
Value: "foo",
Path: "/",
HttpOnly: true,
HTTPOnly: true,
Raw: "ASP.NET_SessionId=foo; path=/; HttpOnly",
}},
},
Expand Down Expand Up @@ -512,7 +512,7 @@ func BenchmarkReadSetCookies(b *testing.B) {
Value: "99=YsDT5i3E-CXax-",
Path: "/",
Domain: ".google.ch",
HttpOnly: true,
HTTPOnly: true,
Expires: time.Date(2011, 11, 23, 1, 5, 3, 0, time.UTC),
RawExpires: "Wed, 23-Nov-2011 01:05:03 GMT",
Raw: "NID=99=YsDT5i3E-CXax-; expires=Wed, 23-Nov-2011 01:05:03 GMT; path=/; domain=.google.ch; HttpOnly",
Expand All @@ -523,7 +523,7 @@ func BenchmarkReadSetCookies(b *testing.B) {
Path: "/",
Expires: time.Date(2012, 3, 7, 14, 25, 6, 0, time.UTC),
RawExpires: "Wed, 07-Mar-2012 14:25:06 GMT",
HttpOnly: true,
HTTPOnly: true,
Raw: ".ASPXAUTH=7E3AA; expires=Wed, 07-Mar-2012 14:25:06 GMT; path=/; HttpOnly",
},
}
Expand Down
2 changes: 1 addition & 1 deletion src/net/http/cookiejar/jar.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ func (j *Jar) newEntry(c *http.Cookie, now time.Time, defPath, host string) (e e

e.Value = c.Value
e.Secure = c.Secure
e.HttpOnly = c.HttpOnly
e.HttpOnly = c.HTTPOnly

switch c.SameSite {
case http.SameSiteDefaultMode:
Expand Down
17 changes: 17 additions & 0 deletions src/net/http/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"net/http"
"os"
"os/signal"
"strings"
)

func ExampleHijacker() {
Expand Down Expand Up @@ -191,3 +192,19 @@ func ExampleNotFoundHandler() {

log.Fatal(http.ListenAndServe(":8080", mux))
}

func ExamplePost() {
r, e := http.Post("http://127.0.0.1/count", "text/plain", strings.NewReader("POST data"))
defer r.Body.Close()
if e != nil {
fmt.Println(e)
}

b, e := ioutil.ReadAll(r.Body)
if e != nil {
fmt.Println(e)
}

fmt.Printf("%s\n", b)

}
32 changes: 16 additions & 16 deletions src/net/http/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ import (
)

var (
DefaultUserAgent = defaultUserAgent
NewLoggingConn = newLoggingConn
ExportAppendTime = appendTime
ExportRefererForURL = refererForURL
ExportServerNewConn = (*Server).newConn
ExportCloseWriteAndWait = (*conn).closeWriteAndWait
ExportErrRequestCanceled = errRequestCanceled
ExportErrRequestCanceledConn = errRequestCanceledConn
ExportErrServerClosedIdle = errServerClosedIdle
ExportServeFile = serveFile
ExportScanETag = scanETag
ExportHttp2ConfigureServer = http2ConfigureServer
Export_shouldCopyHeaderOnRedirect = shouldCopyHeaderOnRedirect
Export_writeStatusLine = writeStatusLine
DefaultUserAgent = defaultUserAgent
NewLoggingConn = newLoggingConn
ExportAppendTime = appendTime
ExportRefererForURL = refererForURL
ExportServerNewConn = (*Server).newConn
ExportCloseWriteAndWait = (*conn).closeWriteAndWait
ExportErrRequestCanceled = errRequestCanceled
ExportErrRequestCanceledConn = errRequestCanceledConn
ExportErrServerClosedIdle = errServerClosedIdle
ExportServeFile = serveFile
ExportScanETag = scanETag
ExportHTTP2ConfigureServer = http2ConfigureServer
ExportShouldCopyHeaderOnRedirect = shouldCopyHeaderOnRedirect
ExportWriteStatusLine = writeStatusLine
)

const MaxWriteWaitBeforeConnReuse = maxWriteWaitBeforeConnReuse
Expand Down Expand Up @@ -134,7 +134,7 @@ func (t *Transport) IdleConnStrsForTesting() []string {
return ret
}

func (t *Transport) IdleConnStrsForTesting_h2() []string {
func (t *Transport) IdleConnStrsForTestingH2() []string {
var ret []string
noDialPool := t.h2transport.(*http2Transport).ConnPool.(http2noDialClientConnPool)
pool := noDialPool.http2clientConnPool
Expand Down Expand Up @@ -212,7 +212,7 @@ func hookSetter(dst *func()) func(func()) {
}
}

func ExportHttp2ConfigureTransport(t *Transport) error {
func ExportHTTP2ConfigureTransport(t *Transport) error {
t2, err := http2configureTransport(t)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion src/net/http/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ func (r *Request) expectsContinue() bool {
return hasToken(r.Header.get("Expect"), "100-continue")
}

func (r *Request) wantsHttp10KeepAlive() bool {
func (r *Request) wantsHTTP10KeepAlive() bool {
if r.ProtoMajor != 1 || r.ProtoMinor != 0 {
return false
}
Expand Down
12 changes: 6 additions & 6 deletions src/net/http/serve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ func TestHTTP2WriteDeadlineExtendedOnNewRequest(t *testing.T) {
defer ts.Close()

c := ts.Client()
if err := ExportHttp2ConfigureTransport(c.Transport.(*Transport)); err != nil {
if err := ExportHTTP2ConfigureTransport(c.Transport.(*Transport)); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -830,8 +830,8 @@ func testHTTP2WriteDeadlineEnforcedPerStream(timeout time.Duration) error {
defer ts.Close()

c := ts.Client()
if err := ExportHttp2ConfigureTransport(c.Transport.(*Transport)); err != nil {
return fmt.Errorf("ExportHttp2ConfigureTransport: %v", err)
if err := ExportHTTP2ConfigureTransport(c.Transport.(*Transport)); err != nil {
return fmt.Errorf("ExportHTTP2ConfigureTransport: %v", err)
}

req, err := NewRequest("GET", ts.URL, nil)
Expand Down Expand Up @@ -890,8 +890,8 @@ func testHTTP2NoWriteDeadline(timeout time.Duration) error {
defer ts.Close()

c := ts.Client()
if err := ExportHttp2ConfigureTransport(c.Transport.(*Transport)); err != nil {
return fmt.Errorf("ExportHttp2ConfigureTransport: %v", err)
if err := ExportHTTP2ConfigureTransport(c.Transport.(*Transport)); err != nil {
return fmt.Errorf("ExportHTTP2ConfigureTransport: %v", err)
}

for i := 0; i < 2; i++ {
Expand Down Expand Up @@ -6004,7 +6004,7 @@ func BenchmarkResponseStatusLine(b *testing.B) {
bw := bufio.NewWriter(ioutil.Discard)
var buf3 [3]byte
for pb.Next() {
Export_writeStatusLine(bw, true, 200, buf3[:])
ExportWriteStatusLine(bw, true, 200, buf3[:])
}
})
}
20 changes: 10 additions & 10 deletions src/net/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ func (c *conn) readRequest(ctx context.Context) (w *response, err error) {
// We populate these ahead of time so we're not
// reading from req.Header after their Handler starts
// and maybe mutates it (Issue 14940)
wants10KeepAlive: req.wantsHttp10KeepAlive(),
wants10KeepAlive: req.wantsHTTP10KeepAlive(),
wantsClose: req.wantsClose(),
}
if isH2Upgrade {
Expand Down Expand Up @@ -2810,7 +2810,7 @@ func (srv *Server) Serve(l net.Listener) error {
l = &onceCloseListener{Listener: l}
defer l.Close()

if err := srv.setupHTTP2_Serve(); err != nil {
if err := srv.setupHTTP2Serve(); err != nil {
return err
}

Expand Down Expand Up @@ -2868,7 +2868,7 @@ func (srv *Server) Serve(l net.Listener) error {
func (srv *Server) ServeTLS(l net.Listener, certFile, keyFile string) error {
// Setup HTTP/2 before srv.Serve, to initialize srv.TLSConfig
// before we clone it and create the TLS Listener.
if err := srv.setupHTTP2_ServeTLS(); err != nil {
if err := srv.setupHTTP2ServeTLS(); err != nil {
return err
}

Expand Down Expand Up @@ -3048,28 +3048,28 @@ func (srv *Server) ListenAndServeTLS(certFile, keyFile string) error {
return srv.ServeTLS(tcpKeepAliveListener{ln.(*net.TCPListener)}, certFile, keyFile)
}

// setupHTTP2_ServeTLS conditionally configures HTTP/2 on
// setupHTTP2ServeTLS conditionally configures HTTP/2 on
// srv and returns whether there was an error setting it up. If it is
// not configured for policy reasons, nil is returned.
func (srv *Server) setupHTTP2_ServeTLS() error {
func (srv *Server) setupHTTP2ServeTLS() error {
srv.nextProtoOnce.Do(srv.onceSetNextProtoDefaults)
return srv.nextProtoErr
}

// setupHTTP2_Serve is called from (*Server).Serve and conditionally
// setupHTTP2Serve is called from (*Server).Serve and conditionally
// configures HTTP/2 on srv using a more conservative policy than
// setupHTTP2_ServeTLS because Serve is called after tls.Listen,
// setupHTTP2ServeTLS because Serve is called after tls.Listen,
// and may be called concurrently. See shouldConfigureHTTP2ForServe.
//
// The tests named TestTransportAutomaticHTTP2* and
// TestConcurrentServerServe in server_test.go demonstrate some
// of the supported use cases and motivations.
func (srv *Server) setupHTTP2_Serve() error {
srv.nextProtoOnce.Do(srv.onceSetNextProtoDefaults_Serve)
func (srv *Server) setupHTTP2Serve() error {
srv.nextProtoOnce.Do(srv.onceSetNextProtoDefaultsServe)
return srv.nextProtoErr
}

func (srv *Server) onceSetNextProtoDefaults_Serve() {
func (srv *Server) onceSetNextProtoDefaultsServe() {
if srv.shouldConfigureHTTP2ForServe() {
srv.onceSetNextProtoDefaults()
}
Expand Down
2 changes: 1 addition & 1 deletion src/net/http/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4236,7 +4236,7 @@ func testTransportIdleConnTimeout(t *testing.T, h2 bool) {

idleConns := func() []string {
if h2 {
return tr.IdleConnStrsForTesting_h2()
return tr.IdleConnStrsForTestingH2()
} else {
return tr.IdleConnStrsForTesting()
}
Expand Down