-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.go
More file actions
50 lines (42 loc) · 825 Bytes
/
Copy pathheader.go
File metadata and controls
50 lines (42 loc) · 825 Bytes
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
package warc
import "strings"
type Header map[string][]string
func (h Header) Set(key, value string) {
h[key] = []string{value}
}
func (h Header) Add(key, value string) {
h[key] = append(h[key], value)
}
func (h Header) Get(key string) string {
lowerKey := strings.ToLower(key)
for k, vv := range h {
if strings.ToLower(k) == lowerKey {
if len(vv) > 0 {
return vv[0]
}
return ""
}
}
return ""
}
func (h Header) Values(key string) []string {
lowerKey := strings.ToLower(key)
for k, vv := range h {
if strings.ToLower(k) == lowerKey {
return vv
}
}
return nil
}
func (h Header) Del(key string) {
lowerKey := strings.ToLower(key)
for k := range h {
if strings.ToLower(k) == lowerKey {
delete(h, k)
return
}
}
}
func NewHeader() Header {
return make(map[string][]string)
}