vendor: update github.com/go-macaron/session

pull/5544/head
Unknwon 2018-12-04 19:36:05 -05:00
parent f2ec0d80a8
commit 458aadbb10
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
4 changed files with 25 additions and 6 deletions

View File

@ -1 +1 @@
0.11.75.1203
0.11.76.1204

View File

@ -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

View File

@ -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

View File

@ -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
}