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

chore: ports interceptor correction #1123

Merged
merged 4 commits into from
Sep 27, 2024
Merged
Changes from all commits
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
11 changes: 9 additions & 2 deletions http/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ func (i *rwInterceptor) Write(b []byte) (int, error) {
// if there is an interruption it must be from at least phase 4 and hence
// WriteHeader or Write should have been called and hence the status code
// has been flushed to the delegated response writer.
return 0, nil
//
// We return the number of bytes as according to the interface io.Writer
// if we don't return an error, the number of bytes written is len(p).
// See https://pkg.go.dev/io#Writer
return len(b), nil
}

if !i.wroteHeader {
Expand All @@ -102,7 +106,10 @@ func (i *rwInterceptor) Write(b []byte) (int, error) {
i.overrideWriteHeader(obtainStatusCodeFromInterruptionOrDefault(it, i.statusCode))
// We only flush the status code after an interruption.
i.flushWriteHeader()
return 0, nil
// We return the number of bytes as according to the interface io.Writer
// if we don't return an error, the number of bytes written is len(p).
// See https://pkg.go.dev/io#Writer
return len(b), nil
}
return n, err
}
Expand Down
Loading