Skip to content

Commit ffa77c8

Browse files
committed
Lint: fix SA1019 http.CloseNotifier is duprecated of staticcheck caddyserver#2541
1 parent 6fdef42 commit ffa77c8

File tree

3 files changed

+1
-29
lines changed

3 files changed

+1
-29
lines changed

caddyhttp/httpserver/responsewriterwrapper.go

+1-12
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
)
2222

2323
// ResponseWriterWrapper wrappers underlying ResponseWriter
24-
// and inherits its Hijacker/Pusher/CloseNotifier/Flusher as well.
24+
// and inherits its Hijacker/Pusher/Flusher as well.
2525
type ResponseWriterWrapper struct {
2626
http.ResponseWriter
2727
}
@@ -45,16 +45,6 @@ func (rww *ResponseWriterWrapper) Flush() {
4545
}
4646
}
4747

48-
// CloseNotify implements http.CloseNotifier.
49-
// It just inherits the underlying ResponseWriter's CloseNotify method.
50-
// It panics if the underlying ResponseWriter is not a CloseNotifier.
51-
func (rww *ResponseWriterWrapper) CloseNotify() <-chan bool {
52-
if cn, ok := rww.ResponseWriter.(http.CloseNotifier); ok {
53-
return cn.CloseNotify()
54-
}
55-
panic(NonCloseNotifierError{Underlying: rww.ResponseWriter})
56-
}
57-
5848
// Push implements http.Pusher.
5949
// It just inherits the underlying ResponseWriter's Push method.
6050
// It panics if the underlying ResponseWriter is not a Pusher.
@@ -71,7 +61,6 @@ type HTTPInterfaces interface {
7161
http.ResponseWriter
7262
http.Pusher
7363
http.Flusher
74-
http.CloseNotifier
7564
http.Hijacker
7665
}
7766

caddyhttp/proxy/proxy.go

-10
Original file line numberDiff line numberDiff line change
@@ -313,16 +313,6 @@ func createUpstreamRequest(rw http.ResponseWriter, r *http.Request) (*http.Reque
313313
// Original incoming server request may be canceled by the
314314
// user or by std lib(e.g. too many idle connections).
315315
ctx, cancel := context.WithCancel(r.Context())
316-
if cn, ok := rw.(http.CloseNotifier); ok {
317-
notifyChan := cn.CloseNotify()
318-
go func() {
319-
select {
320-
case <-notifyChan:
321-
cancel()
322-
case <-ctx.Done():
323-
}
324-
}()
325-
}
326316

327317
outreq := r.WithContext(ctx) // includes shallow copies of maps, but okay
328318

caddyhttp/proxy/proxy_test.go

-7
Original file line numberDiff line numberDiff line change
@@ -1361,13 +1361,6 @@ func TestCancelRequest(t *testing.T) {
13611361
backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
13621362
close(reqInFlight) // cause the client to cancel its request
13631363

1364-
select {
1365-
case <-time.After(10 * time.Second):
1366-
t.Error("Handler never saw CloseNotify")
1367-
return
1368-
case <-w.(http.CloseNotifier).CloseNotify():
1369-
}
1370-
13711364
w.WriteHeader(http.StatusOK)
13721365
w.Write([]byte("Hello, client"))
13731366
}))

0 commit comments

Comments
 (0)