Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use timestamps in GMT format per RFC2616 #772

Merged
merged 2 commits into from
Dec 18, 2022
Merged

Conversation

falentio
Copy link
Contributor

it seems http.TimeFormat used to format time that related with http header, and nocache middleware was not use that(time.RFC1123 instead)

Copy link
Contributor

@VojtechVitek VojtechVitek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any benefit to switching to a GMT (UTC) format? Can you point us at any RFC?

@@ -9,7 +9,7 @@ import (
)

// Unix epoch time
var epoch = time.Unix(0, 0).Format(time.RFC1123)
var epoch = time.Unix(0, 0).Format(http.TimeFormat)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://pkg.go.dev/net/http#TimeFormat
"The time being formatted must be in UTC for Format to generate the correct format."

This is not correct

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry my bad, fixed in recent commit

@falentio
Copy link
Contributor Author

here is the rfc that all http date must be represented in GMT
https://www.rfc-editor.org/rfc/rfc2616#section-3.3

@falentio
Copy link
Contributor Author

also here , GMT in format was represent the time was UTC

@VojtechVitek
Copy link
Contributor

- All HTTP date/time stamps MUST be represented in Greenwich Mean Time
   (GMT), without exception. For the purposes of HTTP, GMT is exactly
   equal to UTC (Coordinated Universal Time). This is indicated in the
   first two formats by the inclusion of "GMT" as the three-letter
   abbreviation for time zone, and MUST be assumed when reading the
   asctime format. HTTP-date is case sensitive and MUST NOT include
   additional LWS beyond that specifically included as SP in the
   grammar.

- All expiration-related calculations MUST be done in GMT. The
        local time zone MUST NOT influence the calculation or comparison
        of an age or expiration time.

- If an HTTP header incorrectly carries a date value with a time
        zone other than GMT, it MUST be converted into GMT using the
        most conservative possible conversion.

Copy link
Contributor

@VojtechVitek VojtechVitek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@VojtechVitek VojtechVitek changed the title using http.TimeFormat as it intended to formatting http header Use timestamps in GMT format per RFC2616 Dec 18, 2022
@pkieltyka pkieltyka merged commit e6baba6 into go-chi:master Dec 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants