refactor, dedup & pass-forward

This commit is contained in:
6543 2022-11-07 23:21:35 +01:00
parent 0339a52efc
commit f31c0b1659
No known key found for this signature in database
GPG key ID: B8BE6D610E61C862
3 changed files with 17 additions and 17 deletions

View file

@ -16,8 +16,6 @@ import (
)
const (
headerContentType = "Content-Type"
headerETag = "ETag"
headerLastModified = "Last-Modified"
headerIfModifiedSince = "If-Modified-Since"
@ -155,11 +153,13 @@ func (o *Options) Upstream(ctx *context.Context, giteaClient *gitea.Client) (fin
// Set ETag & MIME
if res != nil {
ctx.Response().Header.Set(headerETag, res.Header.Get(headerETag))
ctx.Response().Header.Set(gitea.ETagHeader, res.Header.Get(gitea.ETagHeader))
ctx.Response().Header.Set(gitea.PagesCacheIndicatorHeader, res.Header.Get(gitea.PagesCacheIndicatorHeader))
ctx.Response().Header.Set(gitea.ContentLengthHeader, res.Header.Get(gitea.ContentLengthHeader))
if o.ServeRaw {
ctx.Response().Header.Set(headerContentType, res.Header.Get(headerContentType))
ctx.Response().Header.Set(gitea.ContentTypeHeader, res.Header.Get(gitea.ContentTypeHeader))
} else {
ctx.Response().Header.Set(headerContentType, rawMime)
ctx.Response().Header.Set(gitea.ContentTypeHeader, rawMime)
}
}