* Ensure responses are context.ResponseWriters (#19843) Backport #19843 In order for web.Wrap to be able to detect if a response has been written we need to wrap any non-context.ResponseWriters as a such. Otherwise responses will be incorrectly detected as non-written to and handlers can double run. In the case of GZip this handler will change the response to a non-context.RW and this failure to correctly detect response writing causes fallthrough and a NPE. Fix #19839 Signed-off-by: Andrew Thornton <art27@cantab.net> * fix test Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
cf6694e815
commit
daf14b275a
2 changed files with 27 additions and 20 deletions
|
@ -53,6 +53,7 @@ func TestRoute2(t *testing.T) {
|
|||
tp := chi.URLParam(req, "type")
|
||||
assert.EqualValues(t, "issues", tp)
|
||||
route = 0
|
||||
resp.WriteHeader(200)
|
||||
})
|
||||
|
||||
r.Get("/{type:issues|pulls}/{index}", func(resp http.ResponseWriter, req *http.Request) {
|
||||
|
@ -65,9 +66,8 @@ func TestRoute2(t *testing.T) {
|
|||
index := chi.URLParam(req, "index")
|
||||
assert.EqualValues(t, "1", index)
|
||||
route = 1
|
||||
resp.WriteHeader(200)
|
||||
})
|
||||
}, func(resp http.ResponseWriter, req *http.Request) {
|
||||
resp.WriteHeader(200)
|
||||
})
|
||||
|
||||
r.Group("/issues/{index}", func() {
|
||||
|
@ -79,6 +79,7 @@ func TestRoute2(t *testing.T) {
|
|||
index := chi.URLParam(req, "index")
|
||||
assert.EqualValues(t, "1", index)
|
||||
route = 2
|
||||
resp.WriteHeader(200)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue