diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2022-08-25 18:05:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-25 12:05:21 -0400 |
commit | dc0253b0637bbf367ad330612900e780c6b2b0e6 (patch) | |
tree | 85a51c2e9b355bef889e6fdae2e71b49fd645fbb /modules/context | |
parent | 5e232e86de6bb26038e0ebaec60368d54a327446 (diff) | |
download | gitea-dc0253b0637bbf367ad330612900e780c6b2b0e6.tar.gz gitea-dc0253b0637bbf367ad330612900e780c6b2b0e6.zip |
Replace `ServeStream` with `ServeContent` (#20903)
* Replace ServeStream with ServeContent.
* Update modules/timeutil/timestamp.go
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'modules/context')
-rw-r--r-- | modules/context/context.go | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/modules/context/context.go b/modules/context/context.go index 0b9898acef..45f1978e97 100644 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -358,14 +358,7 @@ func (ctx *Context) SetServeHeaders(filename string) { } // ServeContent serves content to http request -func (ctx *Context) ServeContent(name string, r io.ReadSeeker, params ...interface{}) { - modTime := time.Now() - for _, p := range params { - switch v := p.(type) { - case time.Time: - modTime = v - } - } +func (ctx *Context) ServeContent(name string, r io.ReadSeeker, modTime time.Time) { ctx.SetServeHeaders(name) http.ServeContent(ctx.Resp, ctx.Req, name, modTime, r) } @@ -382,15 +375,6 @@ func (ctx *Context) ServeFile(file string, names ...string) { http.ServeFile(ctx.Resp, ctx.Req, file) } -// ServeStream serves file via io stream -func (ctx *Context) ServeStream(rd io.Reader, name string) { - ctx.SetServeHeaders(name) - _, err := io.Copy(ctx.Resp, rd) - if err != nil { - ctx.ServerError("Download file failed", err) - } -} - // UploadStream returns the request body or the first form file // Only form files need to get closed. func (ctx *Context) UploadStream() (rd io.ReadCloser, needToClose bool, err error) { |