Skip to content

Commit

Permalink
Fix an issue which prevents blockwise xfer working with observe
Browse files Browse the repository at this point in the history
If you observe a resource and the state change is too big for a single
packet, it will be sent blockwise. However, only the first block is
sent with the observe token, it is expected that clients will request
subsequent blocks by issuing a new request. Returning a response to
this new request would fail on the client due to ETags not matching,
despite no ETags being used. The failure error was:

  received message doesn't contains ETAG but cached received message contains it([])

This patch ensures that the received message actually contains an
ETag, which fixes this issue.
  • Loading branch information
kegsay authored and jkralik committed Feb 26, 2021
1 parent fe45892 commit 4d46680
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions net/blockwise/blockwise.go
Original file line number Diff line number Diff line change
Expand Up @@ -736,9 +736,13 @@ func (b *BlockWise) processReceivedMessage(w ResponseWriter, r Message, maxSzx S
cachedReceivedMessageETAG, errCachedReceivedMessageETAG := cachedReceivedMessage.GetOptionBytes(message.ETag)
switch {
case errETAG == nil && errCachedReceivedMessageETAG != nil:
return fmt.Errorf("received message doesn't contains ETAG but cached received message contains it(%v)", cachedReceivedMessageETAG)
if len(cachedReceivedMessageETAG) > 0 { // make sure there is an etag there
return fmt.Errorf("received message doesn't contains ETAG but cached received message contains it(%v)", cachedReceivedMessageETAG)
}
case errETAG != nil && errCachedReceivedMessageETAG == nil:
return fmt.Errorf("received message contains ETAG(%v) but cached received message doesn't", rETAG)
if len(rETAG) > 0 { // make sure there is an etag there
return fmt.Errorf("received message contains ETAG(%v) but cached received message doesn't", rETAG)
}
case !bytes.Equal(rETAG, cachedReceivedMessageETAG):
return fmt.Errorf("received message ETAG(%v) is not equal to cached received message ETAG(%v)", rETAG, cachedReceivedMessageETAG)
}
Expand Down

0 comments on commit 4d46680

Please sign in to comment.