ing
This commit is contained in:
parent
2423b22685
commit
2f3869c451
|
@ -73,6 +73,10 @@ type ServerRequestCodec struct {
|
|||
codec codec.Codec
|
||||
}
|
||||
|
||||
func (src *ServerRequestCodec) HasResponse() bool {
|
||||
return src.req.ID != nil
|
||||
}
|
||||
|
||||
// Method returns the RPC method for the current request.
|
||||
//
|
||||
// The method uses a dotted notation as in "Service.Method".
|
||||
|
@ -149,7 +153,7 @@ func (src *ServerRequestCodec) WriteError(w io.Writer, status int, err error) er
|
|||
|
||||
func (src *ServerRequestCodec) writeServerResponse(w io.Writer, res *serverResponse) error {
|
||||
// ID is null for notifications and they don't have a response.
|
||||
if res.ID != nil {
|
||||
if src.req.ID != nil {
|
||||
encoder := json.NewEncoder(src.codec.Encode(w))
|
||||
// Not sure in which case will this happen. But seems harmless.
|
||||
if err := encoder.Encode(res); nil != err {
|
||||
|
|
|
@ -15,6 +15,7 @@ type ServerCodec interface {
|
|||
type ServerRequestCodec interface {
|
||||
RegistryCodec
|
||||
|
||||
HasResponse() bool
|
||||
WriteResponse(w io.Writer, reply interface{}) error
|
||||
WriteError(w io.Writer, status int, err error) error
|
||||
}
|
||||
|
|
|
@ -239,6 +239,10 @@ func handleRequest(s *rpcServlet, requestCodec protocol.ServerRequestCodec) {
|
|||
|
||||
result, err := s.sh.Invoke(s.ctx, requestCodec)
|
||||
|
||||
if !requestCodec.HasResponse() {
|
||||
return
|
||||
}
|
||||
|
||||
rs := &responseState{
|
||||
requestCodec: requestCodec,
|
||||
result: result,
|
||||
|
|
Loading…
Reference in New Issue
Block a user