1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
11 type ResponseWriter interface {
17 // responseWriter wraps http.ResponseWriter and exposes the status
18 // sent, the number of bytes sent to the client, and the last write
20 type responseWriter struct {
22 wroteStatus int // Last status given to WriteHeader()
23 wroteBodyBytes int // Bytes successfully written
24 err error // Last error returned from Write()
27 func WrapResponseWriter(orig http.ResponseWriter) ResponseWriter {
28 return &responseWriter{ResponseWriter: orig}
31 func (w *responseWriter) WriteHeader(s int) {
33 w.ResponseWriter.WriteHeader(s)
36 func (w *responseWriter) Write(data []byte) (n int, err error) {
37 n, err = w.ResponseWriter.Write(data)
43 func (w *responseWriter) WroteStatus() int {
47 func (w *responseWriter) WroteBodyBytes() int {
48 return w.wroteBodyBytes
51 func (w *responseWriter) Err() error {