endpoint Remote: fix broken Send endpoint for DryRun=true

This commit is contained in:
Christian Schwarz 2018-09-24 12:27:57 +02:00
parent ffe33aff3d
commit 9c86e03384

View File

@ -401,9 +401,13 @@ func (s Remote) Send(ctx context.Context, r *pdu.SendReq) (*pdu.SendRes, io.Read
if err != nil {
return nil, nil, err
}
if rs == nil {
if !r.DryRun && rs == nil {
return nil, nil, errors.New("response does not contain a stream")
}
if r.DryRun && rs != nil {
rs.Close()
return nil, nil, errors.New("response contains unexpected stream (was dry run)")
}
var res pdu.SendRes
if err := proto.Unmarshal(rb.Bytes(), &res); err != nil {
rs.Close()