From 59adfc22517afc19d68c9fe7cdcb8809acd914eb Mon Sep 17 00:00:00 2001 From: Peter Gerber Date: Mon, 15 Jul 2024 23:09:33 +0200 Subject: [PATCH] Use correct timestamp format for Last-Modified header HTTP uses GMT [1,2] rather than UTC as timezone for timestamps. However, the Last-Modified header used UTC which confused at least wget. Before, UTC was used: $ wget --no-check-certificate -S --spider https://cb_pages_tests.localhost.mock.directory:4430/images/827679288a.jpg ... Last-Modified: Sun, 11 Sep 2022 08:37:42 UTC ... Last-modified header invalid -- time-stamp ignored. ... After, GMT is used: $ wget --no-check-certificate -S --spider https://cb_pages_tests.localhost.mock.directory:4430/images/827679288a.jpg ... Last-Modified: Sun, 11 Sep 2022 08:37:42 GMT ... (no last-modified-header-invalid warning) [1]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Last-Modified [2]: https://www.rfc-editor.org/rfc/rfc9110#name-date-time-formats Fixes #364 --- server/upstream/header.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/upstream/header.go b/server/upstream/header.go index 9575a3f..7b85df1 100644 --- a/server/upstream/header.go +++ b/server/upstream/header.go @@ -24,5 +24,5 @@ func (o *Options) setHeader(ctx *context.Context, header http.Header) { } else { ctx.RespWriter.Header().Set(gitea.ContentTypeHeader, mime) } - ctx.RespWriter.Header().Set(headerLastModified, o.BranchTimestamp.In(time.UTC).Format(time.RFC1123)) + ctx.RespWriter.Header().Set(headerLastModified, o.BranchTimestamp.In(time.UTC).Format(http.TimeFormat)) }