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