From b7e5857be962ae415f01da8545fff6fc8beb6141 Mon Sep 17 00:00:00 2001 From: Matteo Pace Date: Fri, 27 Sep 2024 20:12:12 +0200 Subject: [PATCH] chore: ports interceptor correction (#1123) chore: port interceptor correction --- http/interceptor.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 }