1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-30 08:17:18 +00:00

fix: ctx.Record and then iris.Compression flow

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-07-30 20:13:59 +03:00
parent 53c6f46941
commit eacbcea653
5 changed files with 119 additions and 18 deletions

View File

@@ -3,6 +3,7 @@ package context
import (
"bufio"
"errors"
"io"
"net"
"net/http"
"sync"
@@ -68,8 +69,8 @@ type ResponseWriter interface {
// it copies the header, status code, headers and the beforeFlush finally returns a new ResponseRecorder.
Clone() ResponseWriter
// WiteTo writes a response writer (temp: status code, headers and body) to another response writer
WriteTo(ResponseWriter)
// CopyTo writes a response writer (temp: status code, headers and body) to another response writer
CopyTo(ResponseWriter)
// Flusher indicates if `Flush` is supported by the client.
//
@@ -112,6 +113,16 @@ type ResponseWriterReseter interface {
Reset() bool
}
// ResponseWriterWriteTo can be implemented
// by response writers that needs a special
// encoding before writing to their buffers.
// E.g. a custom recorder that wraps a custom compressed one.
//
// Not used by the framework itself.
type ResponseWriterWriteTo interface {
WriteTo(dest io.Writer, p []byte)
}
// +------------------------------------------------------------+
// | Response Writer Implementation |
// +------------------------------------------------------------+
@@ -300,8 +311,8 @@ func (w *responseWriter) Clone() ResponseWriter {
return wc
}
// WriteTo writes a response writer (temp: status code, headers and body) to another response writer.
func (w *responseWriter) WriteTo(to ResponseWriter) {
// CopyTo writes a response writer (temp: status code, headers and body) to another response writer.
func (w *responseWriter) CopyTo(to ResponseWriter) {
// set the status code, failure status code are first class
if w.statusCode >= 400 {
to.WriteHeader(w.statusCode)