2016-03-06 20:53:23 -08:00
|
|
|
package test
|
|
|
|
|
|
|
|
import "net/http"
|
|
|
|
|
|
|
|
type (
|
|
|
|
Header struct {
|
|
|
|
header http.Header
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func (h *Header) Add(key, val string) {
|
|
|
|
h.header.Add(key, val)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Header) Del(key string) {
|
|
|
|
h.header.Del(key)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Header) Get(key string) string {
|
|
|
|
return h.header.Get(key)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Header) Set(key, val string) {
|
|
|
|
h.header.Set(key, val)
|
|
|
|
}
|
|
|
|
|
2016-03-16 16:27:31 -07:00
|
|
|
func (h *Header) Keys() (keys []string) {
|
|
|
|
keys = make([]string, len(h.header))
|
|
|
|
i := 0
|
|
|
|
for k := range h.header {
|
|
|
|
keys[i] = k
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2016-05-22 07:58:21 -07:00
|
|
|
func (h *Header) Contains(key string) bool {
|
|
|
|
_, ok := h.header[key]
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2016-03-06 20:53:23 -08:00
|
|
|
func (h *Header) reset(hdr http.Header) {
|
|
|
|
h.header = hdr
|
|
|
|
}
|