Skip to content

Commit

Permalink
fix several bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
localvar committed Apr 17, 2022
1 parent 8c50b9e commit 429ab44
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkg/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (ctx *Context) TargetResponseID() string {
// Response returns the default response, and the return value could
// be nil.
func (ctx *Context) Response() protocols.Response {
return ctx.GetRequest(DefaultResponseID)
return ctx.GetResponse(DefaultResponseID)
}

// Responses returns all responses.
Expand Down
11 changes: 5 additions & 6 deletions pkg/filters/proxy/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,8 @@ func (spCtx *serverPoolContext) prepareRequest(ctx stdcontext.Context) error {

func (spCtx *serverPoolContext) start(spanName string) {
spCtx.startTime = fasttime.Now()
if spanName == "" {
spanName = spCtx.svr.URL
}

span := spCtx.Span().NewChildWithStart(spanName, spCtx.startTime)
carrier := opentracing.HTTPHeadersCarrier(spCtx.stdReq.Header)
carrier := opentracing.HTTPHeadersCarrier(spCtx.req.HTTPHeader())
span.Tracer().Inject(span.Context(), opentracing.HTTPHeaders, carrier)
spCtx.span = span
}
Expand Down Expand Up @@ -489,7 +485,10 @@ func (sp *ServerPool) doHandle(stdctx stdcontext.Context, spCtx *serverPoolConte
return serverPoolError{resp.StatusCode, resultFailureCode}
}

sp.memoryCache.Store(spCtx.req, spCtx.resp)
if sp.memoryCache != nil {
sp.memoryCache.Store(spCtx.req, spCtx.resp)
}

return nil
}

Expand Down
8 changes: 3 additions & 5 deletions pkg/object/httpserver/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ func (mi *muxInstance) search(req *http.Request) *route {
if r.path.ipFilterChain == nil {
return r
}
if r.path.ipFilter.Allow(ip) {
if r.path.ipFilterChain.Allow(ip) {
return r
}
return forbidden
Expand All @@ -479,7 +479,7 @@ func (mi *muxInstance) search(req *http.Request) *route {
continue
}

if !host.ipFilter.Allow(ip) {
if !allowIP(host.ipFilter, ip) {
return forbidden
}

Expand All @@ -497,9 +497,7 @@ func (mi *muxInstance) search(req *http.Request) *route {
if len(path.headers) == 0 {
r = &route{code: http.StatusOK, path: path}
mi.putRouteToCache(req, r)
}

if !path.matchHeaders(req) {
} else if !path.matchHeaders(req) {
headerMismatch = true
continue
}
Expand Down

0 comments on commit 429ab44

Please sign in to comment.