aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
4 files changed, 25 insertions, 6 deletions
diff --git a/templates/.VERSION b/templates/.VERSION
index 67ca82d9..31eb16e2 100644
--- a/templates/.VERSION
+++ b/templates/.VERSION
@@ -1 +1 @@
-0.11.75.1203
+0.11.76.1204
diff --git a/vendor/github.com/go-macaron/session/file.go b/vendor/github.com/go-macaron/session/file.go
index 9bbc7aed..64b47f2b 100644
--- a/vendor/github.com/go-macaron/session/file.go
+++ b/vendor/github.com/go-macaron/session/file.go
@@ -81,6 +81,11 @@ func (s *FileStore) Release() error {
s.p.lock.Lock()
defer s.p.lock.Unlock()
+ // Skip encoding if the data is empty
+ if len(s.data) == 0 {
+ return nil
+ }
+
data, err := EncodeGob(s.data)
if err != nil {
return err
diff --git a/vendor/github.com/go-macaron/session/redis/redis.go b/vendor/github.com/go-macaron/session/redis/redis.go
index ca1cf88d..6fe10736 100644
--- a/vendor/github.com/go-macaron/session/redis/redis.go
+++ b/vendor/github.com/go-macaron/session/redis/redis.go
@@ -81,6 +81,11 @@ func (s *RedisStore) ID() string {
// Release releases resource and save data to provider.
func (s *RedisStore) Release() error {
+ // Skip encoding if the data is empty
+ if len(s.data) == 0 {
+ return nil
+ }
+
data, err := session.EncodeGob(s.data)
if err != nil {
return err
diff --git a/vendor/github.com/go-macaron/session/session.go b/vendor/github.com/go-macaron/session/session.go
index 6bd5bdb1..34355607 100644
--- a/vendor/github.com/go-macaron/session/session.go
+++ b/vendor/github.com/go-macaron/session/session.go
@@ -27,7 +27,7 @@ import (
"gopkg.in/macaron.v1"
)
-const _VERSION = "0.5.0"
+const _VERSION = "0.6.0"
func Version() string {
return _VERSION
@@ -95,6 +95,8 @@ type Options struct {
IDLength int
// Configuration section name. Default is "session".
Section string
+ // Ignore release for websocket. Default is false.
+ IgnoreReleaseForWebSocket bool
}
func prepareOptions(options []Options) Options {
@@ -137,6 +139,9 @@ func prepareOptions(options []Options) Options {
if opt.IDLength == 0 {
opt.IDLength = sec.Key("ID_LENGTH").MustInt(16)
}
+ if !opt.IgnoreReleaseForWebSocket {
+ opt.IgnoreReleaseForWebSocket = sec.Key("IGNORE_RELEASE_FOR_WEBSOCKET").MustBool()
+ }
return opt
}
@@ -186,6 +191,10 @@ func Sessioner(options ...Options) macaron.Handler {
ctx.Next()
+ if manager.opt.IgnoreReleaseForWebSocket && ctx.Req.Header.Get("Upgrade") == "websocket" {
+ return
+ }
+
if err = sess.Release(); err != nil {
panic("session(release): " + err.Error())
}
@@ -346,7 +355,7 @@ func (m *Manager) RegenerateId(ctx *macaron.Context) (sess RawStore, err error)
if err != nil {
return nil, err
}
- ck := &http.Cookie{
+ cookie := &http.Cookie{
Name: m.opt.CookieName,
Value: sid,
Path: m.opt.CookiePath,
@@ -355,10 +364,10 @@ func (m *Manager) RegenerateId(ctx *macaron.Context) (sess RawStore, err error)
Domain: m.opt.Domain,
}
if m.opt.CookieLifeTime >= 0 {
- ck.MaxAge = m.opt.CookieLifeTime
+ cookie.MaxAge = m.opt.CookieLifeTime
}
- http.SetCookie(ctx.Resp, ck)
- ctx.Req.AddCookie(ck)
+ http.SetCookie(ctx.Resp, cookie)
+ ctx.Req.AddCookie(cookie)
return sess, nil
}