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-15 08:33:16 +02:00
|
|
|
// Add implements `engine.Header#Add` method.
|
2016-01-29 09:46:11 +02:00
|
|
|
func (h *RequestHeader) Add(key, val string) {
|
|
|
|
// h.RequestHeader.Add(key, val)
|
|
|
|
}
|
|
|
|
|
2016-03-15 08:33:16 +02:00
|
|
|
// Del implements `engine.Header#Del` method.
|
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-15 08:33:16 +02:00
|
|
|
// Set implements `engine.Header#Set` method.
|
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-15 08:33:16 +02:00
|
|
|
// Get implements `engine.Header#Get` method.
|
2016-03-15 04:58:46 +02:00
|
|
|
func (h *RequestHeader) Get(key string) string {
|
|
|
|
return string(h.Peek(key))
|
|
|
|
}
|
|
|
|
|
2016-03-17 01:27:31 +02:00
|
|
|
// Keys implements `engine.Header#Keys` method.
|
|
|
|
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-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-15 08:33:16 +02:00
|
|
|
// Add implements `engine.Header#Add` method.
|
2016-01-29 09:46:11 +02:00
|
|
|
func (h *ResponseHeader) Add(key, val string) {
|
2016-03-15 17:50:43 +02:00
|
|
|
// TODO: https://github.com/valyala/fasthttp/issues/69
|
2016-02-09 08:17:20 +02:00
|
|
|
// h.header.Add(key, val)
|
2016-01-29 09:46:11 +02:00
|
|
|
}
|
|
|
|
|
2016-03-15 08:33:16 +02:00
|
|
|
// Del implements `engine.Header#Del` method.
|
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-15 08:33:16 +02:00
|
|
|
// Get implements `engine.Header#Get` method.
|
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-15 08:33:16 +02:00
|
|
|
// Set implements `engine.Header#Set` method.
|
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-17 01:27:31 +02:00
|
|
|
// Keys implements `engine.Header#Keys` method.
|
|
|
|
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-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
|
|
|
}
|