mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
fix https://github.com/kataras/iris/issues/1608 with the help of @AlbinoGeek for monitoring and together found the source of the problem
This commit is contained in:
parent
a6ec94e1a6
commit
4035ed308c
|
@ -16,6 +16,7 @@ import (
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app := newApp()
|
app := newApp()
|
||||||
|
// app.UseRouter(iris.Compression)
|
||||||
app.Logger().SetLevel("debug")
|
app.Logger().SetLevel("debug")
|
||||||
|
|
||||||
// Open a client, e.g. Postman and visit the below endpoints.
|
// Open a client, e.g. Postman and visit the below endpoints.
|
||||||
|
|
|
@ -238,6 +238,9 @@ func (p *prefixedDir) Open(name string) (http.File, error) {
|
||||||
var (
|
var (
|
||||||
// Compression is a middleware which enables
|
// Compression is a middleware which enables
|
||||||
// writing and reading using the best offered compression.
|
// writing and reading using the best offered compression.
|
||||||
|
// Usage:
|
||||||
|
// app.Use (for matched routes)
|
||||||
|
// app.UseRouter (for both matched and 404s or other HTTP errors).
|
||||||
Compression = func(ctx Context) {
|
Compression = func(ctx Context) {
|
||||||
ctx.CompressWriter(true)
|
ctx.CompressWriter(true)
|
||||||
ctx.CompressReader(true)
|
ctx.CompressReader(true)
|
||||||
|
|
|
@ -345,3 +345,15 @@ func (w *CompressResponseWriter) WriteTo(dest io.Writer, p []byte) (int, error)
|
||||||
cw.Close()
|
cw.Close()
|
||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset implements the ResponseWriterReseter interface.
|
||||||
|
func (w *CompressResponseWriter) Reset() bool {
|
||||||
|
if w.Disabled {
|
||||||
|
// If it's disabled then the underline one is responsible.
|
||||||
|
rs, ok := w.ResponseWriter.(ResponseWriterReseter)
|
||||||
|
return ok && rs.Reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
w.CompressWriter.Reset(w.ResponseWriter)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
|
@ -121,6 +121,7 @@ func (repo *repository) register(route *Route, rule RouteRegisterRule) (*Route,
|
||||||
var defaultOverlapFilter = func(ctx *context.Context) bool {
|
var defaultOverlapFilter = func(ctx *context.Context) bool {
|
||||||
if ctx.IsStopped() {
|
if ctx.IsStopped() {
|
||||||
// It's stopped and the response can be overridden by a new handler.
|
// It's stopped and the response can be overridden by a new handler.
|
||||||
|
// An exception of compress writer, which does not implement Reseter (and it shouldn't):
|
||||||
rs, ok := ctx.ResponseWriter().(context.ResponseWriterReseter)
|
rs, ok := ctx.ResponseWriter().(context.ResponseWriterReseter)
|
||||||
return ok && rs.Reset()
|
return ok && rs.Reset()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user