Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HttContext Reset Bug #254

Merged
merged 3 commits into from
Sep 24, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.HttpConnectionManager
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