Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
Signed-off-by: spacewander <[email protected]>
  • Loading branch information
spacewander committed Nov 9, 2023
1 parent 9479451 commit 99a81cc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
8 changes: 4 additions & 4 deletions pkg/filtermanager/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (

type DecodeWholeRequestFilter interface {
NeedDecodeWholeRequest(headers api.RequestHeaderMap) bool
DecodeRequest(headers api.RequestHeaderMap, buf api.BufferInstance, trailers api.RequestTrailerMap) ResultAction
DecodeRequest(headers api.RequestHeaderMap, data api.BufferInstance, trailers api.RequestTrailerMap) ResultAction
}

type EncodeWholeResponseFilter interface {
NeedEncodeWholeResponse(headers api.ResponseHeaderMap) bool
EncodeResponse(headers api.ResponseHeaderMap, buf api.BufferInstance, trailers api.ResponseTrailerMap) ResultAction
EncodeResponse(headers api.ResponseHeaderMap, data api.BufferInstance, trailers api.ResponseTrailerMap) ResultAction
}

type Filter interface {
Expand Down Expand Up @@ -58,12 +58,12 @@ func (f *PassThroughFilter) EncodeTrailers(trailers ResponseTrailerMap) ResultAc
func (f *PassThroughFilter) OnLog() {}

func (f *PassThroughFilter) NeedDecodeWholeRequest(headers api.RequestHeaderMap) bool { return false }
func (f *PassThroughFilter) DecodeRequest(headers api.RequestHeaderMap, buf api.BufferInstance, trailers api.RequestTrailerMap) ResultAction {
func (f *PassThroughFilter) DecodeRequest(headers api.RequestHeaderMap, data api.BufferInstance, trailers api.RequestTrailerMap) ResultAction {
return Continue
}

func (f *PassThroughFilter) NeedEncodeWholeResponse(headers api.ResponseHeaderMap) bool { return false }
func (f *PassThroughFilter) EncodeResponse(headers api.ResponseHeaderMap, buf api.BufferInstance, trailers api.ResponseTrailerMap) ResultAction {
func (f *PassThroughFilter) EncodeResponse(headers api.ResponseHeaderMap, data api.BufferInstance, trailers api.ResponseTrailerMap) ResultAction {
return Continue
}

Expand Down
22 changes: 12 additions & 10 deletions pkg/filtermanager/filtermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,13 @@ func (m *filterManager) DecodeData(buf api.BufferInstance, endStream bool) capi.
return
}
m.decodeIdx = i
} else {
// the endStream in DecodeHeaders indicates there is no body,
// which is always false here
if m.handleAction(f.DecodeHeaders(m.reqHdr, false)) {
return
}
continue
}

// the endStream in DecodeHeaders indicates there is no body,
// which is always false here
if m.handleAction(f.DecodeHeaders(m.reqHdr, false)) {
return
}
}

Expand Down Expand Up @@ -388,10 +389,11 @@ func (m *filterManager) EncodeData(buf api.BufferInstance, endStream bool) capi.
return
}
m.encodeIdx = i
} else {
if m.handleAction(f.EncodeHeaders(m.rspHdr, false)) {
return
}
continue
}

if m.handleAction(f.EncodeHeaders(m.rspHdr, false)) {
return
}
}

Expand Down

0 comments on commit 99a81cc

Please sign in to comment.