mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2024-11-05 14:07:01 +00:00
6c63b66ce4
we have big functions that handle all stuff ... we should split this into smaler chuncks so we could test them seperate and make clear cuts in what happens where Reviewed-on: https://codeberg.org/Codeberg/pages-server/pulls/135
28 lines
994 B
Go
28 lines
994 B
Go
package upstream
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
"codeberg.org/codeberg/pages/server/context"
|
|
"codeberg.org/codeberg/pages/server/gitea"
|
|
)
|
|
|
|
// setHeader set values to response header
|
|
func (o *Options) setHeader(ctx *context.Context, header http.Header) {
|
|
if eTag := header.Get(gitea.ETagHeader); eTag != "" {
|
|
ctx.RespWriter.Header().Set(gitea.ETagHeader, eTag)
|
|
}
|
|
if cacheIndicator := header.Get(gitea.PagesCacheIndicatorHeader); cacheIndicator != "" {
|
|
ctx.RespWriter.Header().Set(gitea.PagesCacheIndicatorHeader, cacheIndicator)
|
|
}
|
|
if length := header.Get(gitea.ContentLengthHeader); length != "" {
|
|
ctx.RespWriter.Header().Set(gitea.ContentLengthHeader, length)
|
|
}
|
|
if mime := header.Get(gitea.ContentTypeHeader); mime == "" || o.ServeRaw {
|
|
ctx.RespWriter.Header().Set(gitea.ContentTypeHeader, rawMime)
|
|
} else {
|
|
ctx.RespWriter.Header().Set(gitea.ContentTypeHeader, mime)
|
|
}
|
|
ctx.RespWriter.Header().Set(headerLastModified, o.BranchTimestamp.In(time.UTC).Format(time.RFC1123))
|
|
}
|