2023-05-08 05:36:54 -04:00
|
|
|
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
package context
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"net/http"
|
|
|
|
|
2023-05-09 03:34:36 -04:00
|
|
|
"code.gitea.io/gitea/modules/httplib"
|
2023-05-08 05:36:54 -04:00
|
|
|
)
|
|
|
|
|
2023-05-09 03:34:36 -04:00
|
|
|
type ServeHeaderOptions httplib.ServeHeaderOptions
|
2023-05-08 05:36:54 -04:00
|
|
|
|
2023-05-09 03:34:36 -04:00
|
|
|
func (ctx *Context) SetServeHeaders(opt *ServeHeaderOptions) {
|
|
|
|
httplib.ServeSetHeaders(ctx.Resp, (*httplib.ServeHeaderOptions)(opt))
|
2023-05-08 05:36:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ServeContent serves content to http request
|
|
|
|
func (ctx *Context) ServeContent(r io.ReadSeeker, opts *ServeHeaderOptions) {
|
2023-05-09 03:34:36 -04:00
|
|
|
httplib.ServeSetHeaders(ctx.Resp, (*httplib.ServeHeaderOptions)(opts))
|
2023-05-08 05:36:54 -04:00
|
|
|
http.ServeContent(ctx.Resp, ctx.Req, opts.Filename, opts.LastModified, r)
|
|
|
|
}
|