add headers
This commit is contained in:
parent
271b827aa9
commit
ba3b056e76
@ -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
|
||||||
@ -75,16 +78,19 @@ func (c *rpcPlusCodec) ReadRequestBody(b interface{}) error {
|
|||||||
func (c *rpcPlusCodec) WriteResponse(r *response, body interface{}, last bool) error {
|
func (c *rpcPlusCodec) WriteResponse(r *response, body interface{}, last bool) error {
|
||||||
c.buf.wbuf.Reset()
|
c.buf.wbuf.Reset()
|
||||||
m := &codec.Message{
|
m := &codec.Message{
|
||||||
Method: r.ServiceMethod,
|
Method: r.ServiceMethod,
|
||||||
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(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user