From 0a1d1ded4ebd8e44ed42df634e57b0139c398b15 Mon Sep 17 00:00:00 2001 From: Itay Ariel Date: Wed, 4 Oct 2023 22:38:30 +0300 Subject: [PATCH] feat: flush writes to http response on every chunk (#743) Co-authored-by: Jorge Turrado --- CHANGELOG.md | 3 ++- interceptor/middleware/loggingresponsewriter.go | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f2c6f9a..269dd9b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,8 @@ This changelog keeps track of work items that have been completed and are ready ### Fixes -- **Interceptor**: fatal error: concurrent map iteration and map write ([#726](https://github.com/kedacore/http-add-on/issues/726)) +- **Interceptor**: Add support for streaming responses ([#743](https://github.com/kedacore/http-add-on/issues/743)) +- **Interceptor**: Fatal error: concurrent map iteration and map write ([#726](https://github.com/kedacore/http-add-on/issues/726)) - **Interceptor**: Keep original Host in the Host header ([#331](https://github.com/kedacore/http-add-on/issues/331)) - **Interceptor**: Provide graceful shutdown for http servers on SIGINT and SIGTERM ([#731](https://github.com/kedacore/http-add-on/issues/731)) - **Operator**: Remove ScaledObject `name` & `app` custom labels ([#717](https://github.com/kedacore/http-add-on/issues/717)) diff --git a/interceptor/middleware/loggingresponsewriter.go b/interceptor/middleware/loggingresponsewriter.go index 0ebb9c6c..9c893f1c 100644 --- a/interceptor/middleware/loggingresponsewriter.go +++ b/interceptor/middleware/loggingresponsewriter.go @@ -32,6 +32,9 @@ func (lrw *loggingResponseWriter) Header() http.Header { func (lrw *loggingResponseWriter) Write(bytes []byte) (int, error) { n, err := lrw.downstreamResponseWriter.Write(bytes) + if f, ok := lrw.downstreamResponseWriter.(http.Flusher); ok { + f.Flush() + } lrw.bytesWritten += n