1
0
mirror of https://github.com/labstack/echo.git synced 2025-01-12 01:22:21 +02:00

Fixed fasthttp set header issue

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2016-03-13 10:03:39 -07:00
parent 7942e4a77b
commit 13563e9aad
5 changed files with 10 additions and 10 deletions

View File

@ -6,11 +6,11 @@ import "github.com/valyala/fasthttp"
type ( type (
RequestHeader struct { RequestHeader struct {
fasthttp.RequestHeader *fasthttp.RequestHeader
} }
ResponseHeader struct { ResponseHeader struct {
fasthttp.ResponseHeader *fasthttp.ResponseHeader
} }
) )
@ -30,7 +30,7 @@ func (h *RequestHeader) Set(key, val string) {
h.RequestHeader.Set(key, val) h.RequestHeader.Set(key, val)
} }
func (h *RequestHeader) reset(hdr fasthttp.RequestHeader) { func (h *RequestHeader) reset(hdr *fasthttp.RequestHeader) {
h.RequestHeader = hdr h.RequestHeader = hdr
} }
@ -50,6 +50,6 @@ func (h *ResponseHeader) Set(key, val string) {
h.ResponseHeader.Set(key, val) h.ResponseHeader.Set(key, val)
} }
func (h *ResponseHeader) reset(hdr fasthttp.ResponseHeader) { func (h *ResponseHeader) reset(hdr *fasthttp.ResponseHeader) {
h.ResponseHeader = hdr h.ResponseHeader = hdr
} }

View File

@ -26,7 +26,7 @@ func NewRequest(c *fasthttp.RequestCtx) *Request {
return &Request{ return &Request{
RequestCtx: c, RequestCtx: c,
url: &URL{URI: c.URI()}, url: &URL{URI: c.URI()},
header: &RequestHeader{c.Request.Header}, header: &RequestHeader{&c.Request.Header},
} }
} }

View File

@ -26,7 +26,7 @@ type (
func NewResponse(c *fasthttp.RequestCtx) *Response { func NewResponse(c *fasthttp.RequestCtx) *Response {
return &Response{ return &Response{
RequestCtx: c, RequestCtx: c,
header: &ResponseHeader{c.Response.Header}, header: &ResponseHeader{&c.Response.Header},
writer: c, writer: c,
logger: log.New("test"), logger: log.New("test"),
} }

View File

@ -94,14 +94,14 @@ func (s *Server) Start() {
req := s.pool.request.Get().(*Request) req := s.pool.request.Get().(*Request)
reqHdr := s.pool.requestHeader.Get().(*RequestHeader) reqHdr := s.pool.requestHeader.Get().(*RequestHeader)
reqURL := s.pool.url.Get().(*URL) reqURL := s.pool.url.Get().(*URL)
reqHdr.reset(c.Request.Header) reqHdr.reset(&c.Request.Header)
reqURL.reset(c.URI()) reqURL.reset(c.URI())
req.reset(c, reqHdr, reqURL) req.reset(c, reqHdr, reqURL)
// Response // Response
res := s.pool.response.Get().(*Response) res := s.pool.response.Get().(*Response)
resHdr := s.pool.responseHeader.Get().(*ResponseHeader) resHdr := s.pool.responseHeader.Get().(*ResponseHeader)
resHdr.reset(c.Response.Header) resHdr.reset(&c.Response.Header)
res.reset(c, resHdr) res.reset(c, resHdr)
s.handler.ServeHTTP(req, res) s.handler.ServeHTTP(req, res)

4
glide.lock generated
View File

@ -1,8 +1,8 @@
hash: f220137e9ccd9aaf3051be33c3c23ea8abd2c40df6cf96175c3994d482b5e007 hash: f220137e9ccd9aaf3051be33c3c23ea8abd2c40df6cf96175c3994d482b5e007
updated: 2016-03-11T07:51:13.670742959-08:00 updated: 2016-03-13T09:34:16.391046379-07:00
imports: imports:
- name: github.com/klauspost/compress - name: github.com/klauspost/compress
version: 2d3d403f37d2e70b722590bc286076a17422e1f2 version: 006acde2c5d283d2f8b8aa03d8f0cd2891c680cf
subpackages: subpackages:
- flate - flate
- gzip - gzip