mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-25 06:16:58 +00:00
less indirect
This commit is contained in:
parent
b2323ee8a5
commit
7c45a420e4
4 changed files with 34 additions and 35 deletions
|
@ -42,26 +42,25 @@ func (f FileResponse) IsEmpty() bool {
|
|||
return len(f.Body) != 0
|
||||
}
|
||||
|
||||
func (f FileResponse) createHttpResponse() *http.Response {
|
||||
resp := &http.Response{
|
||||
Header: make(http.Header),
|
||||
}
|
||||
func (f FileResponse) createHttpResponse() (http.Header, int) {
|
||||
header := make(http.Header)
|
||||
statusCode := http.StatusInternalServerError
|
||||
|
||||
if f.Exists {
|
||||
resp.StatusCode = http.StatusOK
|
||||
statusCode = http.StatusOK
|
||||
} else {
|
||||
resp.StatusCode = http.StatusNotFound
|
||||
statusCode = http.StatusNotFound
|
||||
}
|
||||
|
||||
if f.IsSymlink {
|
||||
resp.Header.Set(giteaObjectTypeHeader, objTypeSymlink)
|
||||
header.Set(giteaObjectTypeHeader, objTypeSymlink)
|
||||
}
|
||||
resp.Header.Set(ETagHeader, f.ETag)
|
||||
resp.Header.Set(ContentTypeHeader, f.MimeType)
|
||||
resp.Header.Set(ContentLengthHeader, fmt.Sprint(len(f.Body)))
|
||||
resp.Header.Set(PagesCacheIndicatorHeader, "true")
|
||||
header.Set(ETagHeader, f.ETag)
|
||||
header.Set(ContentTypeHeader, f.MimeType)
|
||||
header.Set(ContentLengthHeader, fmt.Sprint(len(f.Body)))
|
||||
header.Set(PagesCacheIndicatorHeader, "true")
|
||||
|
||||
return resp
|
||||
return header, statusCode
|
||||
}
|
||||
|
||||
type BranchTimestamp struct {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue