Skip to content

Commit 43975c4

Browse files
authored
Merge pull request #120 from hidevopsio/release-1.6
fixes the issue that previous data response is being remained on resp…
2 parents e974538 + 2dd1bac commit 43975c4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pkg/app/web/handler.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ func (h *handler) finalizeResponse(ctx context.Context) {
368368
ctx.ResponseError(err.Error(), http.StatusInternalServerError)
369369
}
370370
}
371+
// To clear current context and init for next request to prevent garbage response
372+
ctx.InitResponses()
371373
}
372374
}
373375
return
@@ -403,7 +405,6 @@ func (h *handler) responseWithError(ctx context.Context, numOut int, results []r
403405
}
404406
}
405407

406-
407408
func (h *handler) setErrorResponseCode(ctx context.Context, response model.ResponseInfo) {
408409
if response.GetCode() == 0 {
409410
prevStatusCode := ctx.GetStatusCode()
@@ -426,7 +427,7 @@ func (h *handler) call(ctx context.Context) {
426427
// init responses
427428
log.Debugf("HTTP Handler: %v: %v %v%v", ctx.HandlerIndex(-1), ctx.Method(), ctx.Host(), ctx.Path())
428429
idx := ctx.HandlerIndex(-1)
429-
if idx <= 1 {
430+
if idx <= 1 {
430431
ctx.InitResponses()
431432
}
432433

@@ -442,7 +443,7 @@ func (h *handler) call(ctx context.Context) {
442443
if h.numOut > 1 {
443444
results[0] = reflect.New(h.responses[0].typ.Elem())
444445
}
445-
results[h.numOut - 1] = reflect.ValueOf(reqErr)
446+
results[h.numOut-1] = reflect.ValueOf(reqErr)
446447
}
447448
}
448449
if reqErr == nil {

0 commit comments

Comments
 (0)