diff options
author | Peter De Wachter <pdewacht@gmail.com> | 2019-08-14 17:54:02 +0200 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2019-09-10 20:43:44 -0700 |
commit | 937492f6f554d51d8cae62829b6229071cac994e (patch) | |
tree | 8b1d4a1c142933a7d79ad8c454e99f58bf17fffb /http | |
parent | b94160df725a52af53f113bf27de7a7b8723174c (diff) |
Do not buffer responses in the image proxy
The image proxy buffered the whole image before sending it to the
browser. If the image is large and/or hosted on a slow server, this
caused a long delay before the user's browser could display anything.
Diffstat (limited to 'http')
-rw-r--r-- | http/response/builder.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/http/response/builder.go b/http/response/builder.go index f17c62e..b8ba1ef 100644 --- a/http/response/builder.go +++ b/http/response/builder.go @@ -8,6 +8,7 @@ import ( "compress/flate" "compress/gzip" "fmt" + "io" "net/http" "strings" "time" @@ -84,6 +85,10 @@ func (b *Builder) Write() { b.compress([]byte(v)) case error: b.compress([]byte(v.Error())) + case io.Reader: + // Compression not implemented in this case + b.writeHeaders() + io.Copy(b.w, v) } } |