mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-27 14:13:48 +03:00
http: ReponseWriter prefer ReadFrom if available (#6565)
Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
This commit is contained in:
parent
571f88d86f
commit
f3aead0e4d
1 changed files with 6 additions and 2 deletions
|
@ -42,9 +42,13 @@ func (rww *ResponseWriterWrapper) Push(target string, opts *http.PushOptions) er
|
||||||
return ErrNotImplemented
|
return ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadFrom implements io.ReaderFrom. It simply calls io.Copy,
|
// ReadFrom implements io.ReaderFrom. It retries to use io.ReaderFrom if available,
|
||||||
// which uses io.ReaderFrom if available.
|
// then fallback to io.Copy.
|
||||||
|
// see: https://github.com/caddyserver/caddy/issues/6546
|
||||||
func (rww *ResponseWriterWrapper) ReadFrom(r io.Reader) (n int64, err error) {
|
func (rww *ResponseWriterWrapper) ReadFrom(r io.Reader) (n int64, err error) {
|
||||||
|
if rf, ok := rww.ResponseWriter.(io.ReaderFrom); ok {
|
||||||
|
return rf.ReadFrom(r)
|
||||||
|
}
|
||||||
return io.Copy(rww.ResponseWriter, r)
|
return io.Copy(rww.ResponseWriter, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue