Nitpick Headers to Header
This commit is contained in:
parent
cd9801891e
commit
d306559d8f
@ -105,17 +105,17 @@ func newRpcPlusCodec(req *transport.Message, client transport.Client, c codec.Ne
|
||||
func (c *rpcPlusCodec) WriteRequest(req *request, body interface{}) error {
|
||||
c.buf.wbuf.Reset()
|
||||
m := &codec.Message{
|
||||
Id: req.Seq,
|
||||
Target: req.Service,
|
||||
Method: req.ServiceMethod,
|
||||
Type: codec.Request,
|
||||
Headers: map[string]string{},
|
||||
Id: req.Seq,
|
||||
Target: req.Service,
|
||||
Method: req.ServiceMethod,
|
||||
Type: codec.Request,
|
||||
Header: map[string]string{},
|
||||
}
|
||||
if err := c.codec.Write(m, body); err != nil {
|
||||
return err
|
||||
}
|
||||
c.req.Body = c.buf.wbuf.Bytes()
|
||||
for k, v := range m.Headers {
|
||||
for k, v := range m.Header {
|
||||
c.req.Header[k] = v
|
||||
}
|
||||
return c.client.Send(c.req)
|
||||
|
@ -33,10 +33,10 @@ type Codec interface {
|
||||
// the communication, likely followed by the body.
|
||||
// In the case of an error, body may be nil.
|
||||
type Message struct {
|
||||
Id uint64
|
||||
Type MessageType
|
||||
Target string
|
||||
Method string
|
||||
Error string
|
||||
Headers map[string]string
|
||||
Id uint64
|
||||
Type MessageType
|
||||
Target string
|
||||
Method string
|
||||
Error string
|
||||
Header map[string]string
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ func newRpcPlusCodec(req *transport.Message, socket transport.Socket, c codec.Ne
|
||||
}
|
||||
|
||||
func (c *rpcPlusCodec) ReadRequestHeader(r *request, first bool) error {
|
||||
m := codec.Message{Headers: c.req.Header}
|
||||
m := codec.Message{Header: c.req.Header}
|
||||
|
||||
if !first {
|
||||
var tm transport.Message
|
||||
@ -73,7 +73,7 @@ func (c *rpcPlusCodec) ReadRequestHeader(r *request, first bool) error {
|
||||
return err
|
||||
}
|
||||
|
||||
m.Headers = tm.Header
|
||||
m.Header = tm.Header
|
||||
}
|
||||
|
||||
err := c.codec.ReadHeader(&m, codec.Request)
|
||||
@ -89,19 +89,19 @@ func (c *rpcPlusCodec) ReadRequestBody(b interface{}) error {
|
||||
func (c *rpcPlusCodec) WriteResponse(r *response, body interface{}, last bool) error {
|
||||
c.buf.wbuf.Reset()
|
||||
m := &codec.Message{
|
||||
Method: r.ServiceMethod,
|
||||
Id: r.Seq,
|
||||
Error: r.Error,
|
||||
Type: codec.Response,
|
||||
Headers: map[string]string{},
|
||||
Method: r.ServiceMethod,
|
||||
Id: r.Seq,
|
||||
Error: r.Error,
|
||||
Type: codec.Response,
|
||||
Header: map[string]string{},
|
||||
}
|
||||
if err := c.codec.Write(m, body); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
m.Headers["Content-Type"] = c.req.Header["Content-Type"]
|
||||
m.Header["Content-Type"] = c.req.Header["Content-Type"]
|
||||
return c.socket.Send(&transport.Message{
|
||||
Header: m.Headers,
|
||||
Header: m.Header,
|
||||
Body: c.buf.wbuf.Bytes(),
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user