@@ -67,7 +67,7 @@ func messyEncoding(w http.ResponseWriter, req *http.Request) {
6767 }
6868
6969 for _ , oneencodingfrommany := range soManyEncodings {
70- fmt .Fprint (w , oneencodingfrommany )
70+ _ , _ = fmt .Fprint (w , oneencodingfrommany )
7171 }
7272}
7373
@@ -77,7 +77,7 @@ func superSlow(w http.ResponseWriter, req *http.Request) {
7777 z := w .(http.Flusher )
7878 for name , headers := range req .Header {
7979 for _ , h := range headers {
80- fmt .Fprintf (w , "%v: %v\n " , name , h )
80+ _ , _ = fmt .Fprintf (w , "%v: %v\n " , name , h )
8181 z .Flush ()
8282 time .Sleep (250 * time .Millisecond )
8383 }
@@ -98,7 +98,9 @@ func superSlow(w http.ResponseWriter, req *http.Request) {
9898func emptyResponse (w http.ResponseWriter , req * http.Request ) {
9999 hj , _ := w .(http.Hijacker )
100100 conn , _ , _ := hj .Hijack ()
101- defer conn .Close ()
101+ defer func () {
102+ _ = conn .Close ()
103+ }()
102104}
103105
104106// SO MANY REDIRECTS
@@ -111,7 +113,9 @@ func infiniteRedirects(w http.ResponseWriter, req *http.Request) {
111113func unexpectedEOF (w http.ResponseWriter , req * http.Request ) {
112114 hj , _ := w .(http.Hijacker )
113115 conn , bufrw , _ := hj .Hijack ()
114- defer conn .Close ()
116+ defer func () {
117+ _ = conn .Close ()
118+ }()
115119 // reply with bogus data - this should either crash the client or trigger a recoverable error on
116120 // default retryablehttp requests
117121 _ , _ = bufrw .WriteString ("HTTP/1.1 200 OK\n " +
@@ -121,18 +125,18 @@ func unexpectedEOF(w http.ResponseWriter, req *http.Request) {
121125 // "Content-Length: -124" +
122126 // "Content-Type: whatzdacontenttype" +
123127 // "Connection: drunk")
124- bufrw .Flush ()
128+ _ = bufrw .Flush ()
125129}
126130
127131// Simulate normal 200 answer with body
128132func foo (w http.ResponseWriter , req * http.Request ) {
129- fmt .Fprintf (w , "foo" )
133+ _ , _ = fmt .Fprintf (w , "foo" )
130134}
131135
132136// generates recoverable errors until SuccessAfter attempts => after it 200 + body
133137var count int // as of now a local horrible variable suffice
134138func successAfter (w http.ResponseWriter , req * http.Request ) {
135- var successAfter int = defaultSuccessAfterThreshold
139+ successAfter : = defaultSuccessAfterThreshold
136140 if req .FormValue ("successAfter" ) != "" {
137141 if i , err := strconv .Atoi (req .FormValue ("successAfter" )); err == nil {
138142 successAfter = i
@@ -143,7 +147,9 @@ func successAfter(w http.ResponseWriter, req *http.Request) {
143147 if count <= successAfter {
144148 hj , _ := w .(http.Hijacker )
145149 conn , bufrw , _ := hj .Hijack ()
146- defer conn .Close ()
150+ defer func () {
151+ _ = conn .Close ()
152+ }()
147153 // reply with bogus data - this should either crash the client or trigger a recoverable error on
148154 // default retryablehttp requests
149155 _ , _ = bufrw .WriteString ("HHHTTP\\ 1,.1 -500 MAYBEOK\n " +
@@ -153,17 +159,15 @@ func successAfter(w http.ResponseWriter, req *http.Request) {
153159 "Content-Length: -124\n " +
154160 "Content-Type: whatzdacontenttype\n " +
155161 "Connection: drunk" )
156- bufrw .Flush ()
162+ _ = bufrw .Flush ()
157163 return
158164 }
159165
160166 // zeroes attempts and return 200 + valid body
161167 count = 0
162- fmt .Fprintf (w , "foo" )
168+ _ , _ = fmt .Fprintf (w , "foo" )
163169}
164170
165-
166-
167171var (
168172 server * http.Server
169173 serverTLS * http.Server
0 commit comments