-
Notifications
You must be signed in to change notification settings - Fork 351
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
Feature: io package provides streaming facility for request and response filters #2428
Conversation
My first test of readwrite body ported Because I did not change much, no serious change in the benchmark.
|
b5c4004
to
a4a1e26
Compare
1d04fd9
to
5fc019f
Compare
The blockContent() rewrite benchmark shows good enough results:
|
6d94e05
to
e014a1c
Compare
net/httpbody.go
Outdated
return consumedInput, err | ||
} | ||
if err2 != nil { | ||
return consumedInput, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What error to return here: err
, because it's propagating state of Read or err2
because it is what happened at the Write?
Benchmark for "blocking" case
|
e014a1c
to
c6c0c7d
Compare
args := []interface{}{"foo"} | ||
args2 := []interface{}{"bar"} | ||
r := &eskip.Route{Filters: []*eskip.Filter{ | ||
{Name: spec.Name(), Args: args}, | ||
{Name: spec.Name(), Args: args2}, | ||
}, Backend: backend.URL} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think eskip.MustParse*
would be more readable here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it won't, because of parameters and args will be ugly to put
net/httpbody.go
Outdated
func (m *matcher) Close() error { | ||
var err error | ||
m.once.Do(func() { | ||
m.closed = true | ||
if c, ok := m.input.(io.Closer); ok { | ||
err = c.Close() | ||
} | ||
}) | ||
return err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second call to Close will return nil.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And?
net/httpbody.go
Outdated
func LogBody(ctx context.Context, fmtstr string, log func(format string, args ...interface{}), rc io.ReadCloser) io.ReadCloser { | ||
return newLogBody(ctx, fmtstr, log, rc) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like a simple Reader wrapper. Why do we need it in net package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also does not look related to WrapBody so maybe add it in a separate PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was your suggestion to add it separately from WrapBody.
I think the feature makes sense to have here, because it's usable as it is without dependency to filters for example.
|
||
for _, s := range m.toblockList { | ||
if bytes.Contains(b, s.str) { | ||
b = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copied from here
ed9bc61
to
f4366a9
Compare
feature: implement net.HttpBody to allow streaming filters on http body request and response refactoring: blockContent,blockContentHex filters to use the new implementation refactor: move ErrBlock form proxy to net refactor: reuse types and enum and expose options to set httpbody matcher config drop noleak because of transport related leaks feature: read write body wrapper and test api with porting compress filter Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
…at it can be searched in log analysis Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
rename BodyOptions to BufferOptions Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
f4366a9
to
a56cb3d
Compare
Closing in favor of a PR split into: |
Feature: io.InspectReader provides streaming facility for request and response filters
feature: logBody() request and response filters
refactor: blockContent() and blockContentHex() filters use the new io.InspectReader
This PR state is only done for the log stream read filters.
should fix #2605
Write stream is out of scope and should be done later.