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