fix: expire header timezone (#1840)

Signed-off-by: Jim Ma <majinjing3@gmail.com>
This commit is contained in:
Jim Ma 2022-11-16 18:19:21 +08:00 committed by Gaius
parent 3582a10b91
commit 1c24c3fc8c
No known key found for this signature in database
GPG Key ID: 8B4E5D1290FA2FFB
2 changed files with 8 additions and 4 deletions

View File

@ -435,7 +435,8 @@ func (s *server) recursiveDownloadWithP2PMetadata(
// update url scheme // update url scheme
purl.Scheme = source.ListMetadataScheme purl.Scheme = source.ListMetadataScheme
// update cache expire time // update cache expire time
urlMeta.Header[source.ListMetadataExpire] = time.Now().Add(s.cacheRecursiveMetadata).Format(source.ExpireLayout) // The target format is GMT time, need convert to UTC time first
urlMeta.Header[source.ListMetadataExpire] = time.Now().Add(s.cacheRecursiveMetadata).UTC().Format(source.ExpireLayout)
rc, _, err := s.peerTaskManager.StartStreamTask(ctx, &peer.StreamTaskRequest{ rc, _, err := s.peerTaskManager.StartStreamTask(ctx, &peer.StreamTaskRequest{
URL: purl.String(), URL: purl.String(),

View File

@ -16,7 +16,10 @@
package source package source
import "net/textproto" import (
"net/http"
"net/textproto"
)
const ( const (
// Range is different with HTTP Range, it's without "bytes=" prefix // Range is different with HTTP Range, it's without "bytes=" prefix
@ -24,8 +27,8 @@ const (
) )
const ( const (
LastModifiedLayout = "Mon, 02 Jan 2006 15:04:05 GMT" LastModifiedLayout = http.TimeFormat
ExpireLayout = "Mon, 02 Jan 2006 15:04:05 GMT" ExpireLayout = http.TimeFormat
) )
type ExpireInfo struct { type ExpireInfo struct {