Skip to content

Commit

Permalink
Merge pull request apache#254 from ztelur/bugfix-reset
Browse files Browse the repository at this point in the history
Fix HttContext Reset Bug 

Former-commit-id: 3a15866
  • Loading branch information
williamfeng323 authored Sep 24, 2021
2 parents fee1c31 + 93404a5 commit e1c3452
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/context/http/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type HttpContext struct {
HttpConnectionManager model.HttpConnectionManagerConfig
Listener *model.Listener
Route *model.RouteAction
Api router.API
Api *router.API

Request *http.Request
writermem responseWriter
Expand Down Expand Up @@ -89,7 +89,15 @@ func (hc *HttpContext) Next() {
// Reset reset http context
func (hc *HttpContext) Reset() {
hc.Writer = &hc.writermem
hc.Ctx = nil
hc.Index = -1
hc.Filters = []FilterFunc{}
hc.Route = nil
hc.Api = nil
hc.Err = nil

hc.TargetResp = nil
hc.SourceResp = nil
}

// Status set header status code
Expand Down Expand Up @@ -240,12 +248,12 @@ func (hc *HttpContext) ResetWritermen(w http.ResponseWriter) {
// API sets the API to http context
func (hc *HttpContext) API(api router.API) {
hc.Timeout = api.Timeout
hc.Api = api
hc.Api = &api
}

// GetAPI get api
func (hc *HttpContext) GetAPI() *router.API {
return &hc.Api
return hc.Api
}

// Abort filter chain break , filter after the current filter will not executed.
Expand Down

0 comments on commit e1c3452

Please sign in to comment.