-
Notifications
You must be signed in to change notification settings - Fork 11
/
header.go
67 lines (56 loc) · 1.01 KB
/
header.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package standard
import (
"net/http"
"sync"
)
func NewHeader(header http.Header) *Header {
return &Header{header: header}
}
type Header struct {
header http.Header
lock sync.RWMutex
}
func (h *Header) Add(key string, value string) {
h.lock.Lock()
h.header.Add(key, value)
h.lock.Unlock()
}
func (h *Header) Del(key string) {
h.lock.Lock()
h.header.Del(key)
h.lock.Unlock()
}
func (h *Header) Get(key string) string {
h.lock.RLock()
v := h.header.Get(key)
h.lock.RUnlock()
return v
}
func (h *Header) Values(key string) []string {
h.lock.RLock()
v := h.header.Values(key)
h.lock.RUnlock()
return v
}
func (h *Header) Set(key string, value string) {
h.lock.Lock()
h.header.Set(key, value)
h.lock.Unlock()
}
func (h *Header) reset(hdr http.Header) {
h.lock.Lock()
h.header = hdr
h.lock.Unlock()
}
func (h *Header) Object() interface{} {
h.lock.RLock()
v := h.header
h.lock.RUnlock()
return v
}
func (h *Header) Std() http.Header {
h.lock.RLock()
v := h.header
h.lock.RUnlock()
return v
}