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