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