2016-02-09 21:43:00 +02:00
|
|
|
// +build !appengine
|
|
|
|
|
2016-01-29 09:46:11 +02:00
|
|
|
package fasthttp
|
|
|
|
|
|
|
|
import "github.com/valyala/fasthttp"
|
|
|
|
|
|
|
|
type (
|
2016-03-15 04:58:46 +02:00
|
|
|
// RequestHeader holds `fasthttp.RequestHeader`.
|
2016-01-29 09:46:11 +02:00
|
|
|
RequestHeader struct {
|
2016-03-13 19:03:39 +02:00
|
|
|
*fasthttp.RequestHeader
|
2016-01-29 09:46:11 +02:00
|
|
|
}
|
|
|
|
|
2016-03-15 04:58:46 +02:00
|
|
|
// ResponseHeader holds `fasthttp.ResponseHeader`.
|
2016-01-29 09:46:11 +02:00
|
|
|
ResponseHeader struct {
|
2016-03-13 19:03:39 +02:00
|
|
|
*fasthttp.ResponseHeader
|
2016-01-29 09:46:11 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2016-03-20 00:47:20 +02:00
|
|
|
// Add implements `engine.Header#Add` function.
|
2016-01-29 09:46:11 +02:00
|
|
|
func (h *RequestHeader) Add(key, val string) {
|
2016-03-29 16:22:46 +02:00
|
|
|
h.RequestHeader.Add(key, val)
|
2016-01-29 09:46:11 +02:00
|
|
|
}
|
|
|
|
|
2016-03-20 00:47:20 +02:00
|
|
|
// Del implements `engine.Header#Del` function.
|
2016-01-29 09:46:11 +02:00
|
|
|
func (h *RequestHeader) Del(key string) {
|
2016-03-10 22:05:33 +02:00
|
|
|
h.RequestHeader.Del(key)
|
2016-01-29 09:46:11 +02:00
|
|
|
}
|
|
|
|
|
2016-03-20 00:47:20 +02:00
|
|
|
// Set implements `engine.Header#Set` function.
|
2016-01-29 09:46:11 +02:00
|
|
|
func (h *RequestHeader) Set(key, val string) {
|
2016-03-10 22:05:33 +02:00
|
|
|
h.RequestHeader.Set(key, val)
|
2016-02-21 00:04:09 +02:00
|
|
|
}
|
|
|
|
|
2016-03-20 00:47:20 +02:00
|
|
|
// Get implements `engine.Header#Get` function.
|
2016-03-15 04:58:46 +02:00
|
|
|
func (h *RequestHeader) Get(key string) string {
|
|
|
|
return string(h.Peek(key))
|
|
|
|
}
|
|
|
|
|
2016-03-20 00:47:20 +02:00
|
|
|
// Keys implements `engine.Header#Keys` function.
|
2016-03-17 01:27:31 +02:00
|
|
|
func (h *RequestHeader) Keys() (keys []string) {
|
|
|
|
keys = make([]string, h.Len())
|
|
|
|
i := 0
|
|
|
|
h.VisitAll(func(k, v []byte) {
|
|
|
|
keys[i] = string(k)
|
|
|
|
i++
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2016-05-22 16:58:21 +02:00
|
|
|
// Contains implements `engine.Header#Contains` function.
|
|
|
|
func (h *RequestHeader) Contains(key string) bool {
|
2016-05-23 01:05:38 +02:00
|
|
|
return h.Peek(key) != nil
|
2016-05-22 16:58:21 +02:00
|
|
|
}
|
|
|
|
|
2016-03-13 19:03:39 +02:00
|
|
|
func (h *RequestHeader) reset(hdr *fasthttp.RequestHeader) {
|
2016-03-10 22:05:33 +02:00
|
|
|
h.RequestHeader = hdr
|
2016-02-22 05:58:19 +02:00
|
|
|
}
|
|
|
|
|
2016-03-20 00:47:20 +02:00
|
|
|
// Add implements `engine.Header#Add` function.
|
2016-01-29 09:46:11 +02:00
|
|
|
func (h *ResponseHeader) Add(key, val string) {
|
2016-03-29 16:22:46 +02:00
|
|
|
h.ResponseHeader.Add(key, val)
|
2016-01-29 09:46:11 +02:00
|
|
|
}
|
|
|
|
|
2016-03-20 00:47:20 +02:00
|
|
|
// Del implements `engine.Header#Del` function.
|
2016-01-29 09:46:11 +02:00
|
|
|
func (h *ResponseHeader) Del(key string) {
|
2016-03-10 22:05:33 +02:00
|
|
|
h.ResponseHeader.Del(key)
|
2016-01-29 09:46:11 +02:00
|
|
|
}
|
|
|
|
|
2016-03-20 00:47:20 +02:00
|
|
|
// Get implements `engine.Header#Get` function.
|
2016-01-29 09:46:11 +02:00
|
|
|
func (h *ResponseHeader) Get(key string) string {
|
2016-03-10 22:05:33 +02:00
|
|
|
return string(h.Peek(key))
|
2016-01-29 09:46:11 +02:00
|
|
|
}
|
|
|
|
|
2016-03-20 00:47:20 +02:00
|
|
|
// Set implements `engine.Header#Set` function.
|
2016-01-29 09:46:11 +02:00
|
|
|
func (h *ResponseHeader) Set(key, val string) {
|
2016-03-10 22:05:33 +02:00
|
|
|
h.ResponseHeader.Set(key, val)
|
2016-02-21 00:04:09 +02:00
|
|
|
}
|
2016-02-22 05:58:19 +02:00
|
|
|
|
2016-03-20 00:47:20 +02:00
|
|
|
// Keys implements `engine.Header#Keys` function.
|
2016-03-17 01:27:31 +02:00
|
|
|
func (h *ResponseHeader) Keys() (keys []string) {
|
|
|
|
keys = make([]string, h.Len())
|
|
|
|
i := 0
|
|
|
|
h.VisitAll(func(k, v []byte) {
|
|
|
|
keys[i] = string(k)
|
|
|
|
i++
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2016-05-22 16:58:21 +02:00
|
|
|
// Contains implements `engine.Header#Contains` function.
|
|
|
|
func (h *ResponseHeader) Contains(key string) bool {
|
2016-05-23 01:05:38 +02:00
|
|
|
return h.Peek(key) != nil
|
2016-05-22 16:58:21 +02:00
|
|
|
}
|
|
|
|
|
2016-03-13 19:03:39 +02:00
|
|
|
func (h *ResponseHeader) reset(hdr *fasthttp.ResponseHeader) {
|
2016-03-10 22:05:33 +02:00
|
|
|
h.ResponseHeader = hdr
|
2016-02-22 05:58:19 +02:00
|
|
|
}
|