add headers

This commit is contained in:
Asim 2015-12-16 02:15:09 +00:00
parent 271b827aa9
commit ba3b056e76

View File

@ -61,7 +61,10 @@ func newRpcPlusCodec(req *transport.Message, socket transport.Socket, c codec.Ne
} }
func (c *rpcPlusCodec) ReadRequestHeader(r *request) error { func (c *rpcPlusCodec) ReadRequestHeader(r *request) error {
var m codec.Message m := codec.Message{
Headers: c.req.Header,
}
err := c.codec.ReadHeader(&m, codec.Request) err := c.codec.ReadHeader(&m, codec.Request)
r.ServiceMethod = m.Method r.ServiceMethod = m.Method
r.Seq = m.Id r.Seq = m.Id
@ -79,12 +82,15 @@ func (c *rpcPlusCodec) WriteResponse(r *response, body interface{}, last bool) e
Id: r.Seq, Id: r.Seq,
Error: r.Error, Error: r.Error,
Type: codec.Response, Type: codec.Response,
Headers: map[string]string{},
} }
if err := c.codec.Write(m, body); err != nil { if err := c.codec.Write(m, body); err != nil {
return err return err
} }
m.Headers["Content-Type"] = c.req.Header["Content-Type"]
return c.socket.Send(&transport.Message{ return c.socket.Send(&transport.Message{
Header: map[string]string{"Content-Type": c.req.Header["Content-Type"]}, Header: m.Headers,
Body: c.buf.wbuf.Bytes(), Body: c.buf.wbuf.Bytes(),
}) })
} }