mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-14 15:56:44 +03:00
Issue #29: use time.UTC instead of time.LoadLocation, since this call may fail on systems without certain config files
This commit is contained in:
+3
-9
@@ -12,14 +12,6 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var gmtLocation = func() *time.Location {
|
||||
x, err := time.LoadLocation("GMT")
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("cannot load GMT location: %s", err))
|
||||
}
|
||||
return x
|
||||
}()
|
||||
|
||||
// AppendIPv4 appends string representation of the given ip v4 to dst
|
||||
// and returns the extended dst.
|
||||
func AppendIPv4(dst []byte, ip net.IP) []byte {
|
||||
@@ -78,7 +70,9 @@ func ParseIPv4(dst net.IP, ipStr []byte) (net.IP, error) {
|
||||
// AppendHTTPDate appends HTTP-compliant (RFC1123) representation of date
|
||||
// to dst and returns the extended dst.
|
||||
func AppendHTTPDate(dst []byte, date time.Time) []byte {
|
||||
return date.In(gmtLocation).AppendFormat(dst, time.RFC1123)
|
||||
dst = date.In(time.UTC).AppendFormat(dst, time.RFC1123)
|
||||
copy(dst[len(dst)-3:], strGMT)
|
||||
return dst
|
||||
}
|
||||
|
||||
// ParseHTTPDate parses HTTP-compliant (RFC1123) date.
|
||||
|
||||
@@ -218,7 +218,7 @@ func (c *Cookie) ParseBytes(src []byte) error {
|
||||
switch {
|
||||
case bytes.Equal(strCookieExpires, kv.key):
|
||||
v := unsafeBytesToStr(kv.value)
|
||||
exptime, err := time.ParseInLocation(time.RFC1123, v, gmtLocation)
|
||||
exptime, err := time.ParseInLocation(time.RFC1123, v, time.UTC)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -938,7 +938,7 @@ func fsLastModified(path string) (time.Time, error) {
|
||||
}
|
||||
|
||||
func fsModTime(t time.Time) time.Time {
|
||||
return t.In(gmtLocation).Truncate(time.Second)
|
||||
return t.In(time.UTC).Truncate(time.Second)
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -18,6 +18,7 @@ var (
|
||||
strHTTP11 = []byte("HTTP/1.1")
|
||||
strColonSlashSlash = []byte("://")
|
||||
strColonSpace = []byte(": ")
|
||||
strGMT = []byte("GMT")
|
||||
|
||||
strResponseContinue = []byte("HTTP/1.1 100 Continue\r\n\r\n")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user