Skip to content

Commit

Permalink
chore: ports interceptor correction (#1123)
Browse files Browse the repository at this point in the history
chore: port interceptor correction
  • Loading branch information
M4tteoP authored Sep 27, 2024
1 parent 413c59c commit b7e5857
Showing 1 changed file with 9 additions and 2 deletions.
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

0 comments on commit b7e5857

Please sign in to comment.