diff --git a/http/interceptor.go b/http/interceptor.go index 06d765635..0fa9febab 100644 --- a/http/interceptor.go +++ b/http/interceptor.go @@ -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 { @@ -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 }