6da0cdb9 by JessonChan Committed by astaxie

no need lock here

1 parent 9f070c62
...@@ -47,26 +47,20 @@ import ( ...@@ -47,26 +47,20 @@ import (
47 "net/url" 47 "net/url"
48 "os" 48 "os"
49 "strings" 49 "strings"
50 "sync"
51 "time" 50 "time"
52 ) 51 )
53 52
54 var defaultSetting = BeegoHttpSettings{UserAgent: "beegoServer", ConnectTimeout: 60 * time.Second, ReadWriteTimeout: 60 * time.Second, Gzip: true} 53 var defaultSetting = BeegoHttpSettings{UserAgent: "beegoServer", ConnectTimeout: 60 * time.Second, ReadWriteTimeout: 60 * time.Second, Gzip: true}
55 var defaultCookieJar http.CookieJar 54 var defaultCookieJar http.CookieJar
56 var settingMutex sync.Mutex
57 55
58 // createDefaultCookie creates a global cookiejar to store cookies. 56 // createDefaultCookie creates a global cookiejar to store cookies.
59 func createDefaultCookie() { 57 func createDefaultCookie() {
60 settingMutex.Lock()
61 defaultCookieJar, _ = cookiejar.New(nil) 58 defaultCookieJar, _ = cookiejar.New(nil)
62 settingMutex.Unlock()
63 } 59 }
64 60
65 // Overwrite default settings 61 // Overwrite default settings
66 func SetDefaultSetting(setting BeegoHttpSettings) { 62 func SetDefaultSetting(setting BeegoHttpSettings) {
67 settingMutex.Lock()
68 defaultSetting = setting 63 defaultSetting = setting
69 settingMutex.Unlock()
70 } 64 }
71 65
72 // return *BeegoHttpRequest with specific method 66 // return *BeegoHttpRequest with specific method
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!