mirror of
https://github.com/espressif/openthread.git
synced 2026-06-05 21:14:49 +00:00
[coap] block2 fix PrepareNextBlockRequest to not return error (#12098)
This commit is contained in:
@@ -636,10 +636,14 @@ Error CoapBase::PrepareNextBlockRequest(Message::BlockType aType,
|
||||
bool isOptionSet = false;
|
||||
uint16_t blockOption = 0;
|
||||
Option::Iterator iterator;
|
||||
Metadata metadata;
|
||||
|
||||
blockOption = (aType == Message::kBlockType1) ? kOptionBlock1 : kOptionBlock2;
|
||||
|
||||
aRequest.Init(kTypeConfirmable, static_cast<ot::Coap::Code>(aRequestOld.GetCode()));
|
||||
// Iterate after metadata copied and removed.
|
||||
metadata.ReadFrom(aRequestOld);
|
||||
metadata.RemoveFrom(aRequestOld);
|
||||
// Per RFC 7959, all requests in a block-wise transfer MUST use the same token.
|
||||
IgnoreError(aRequest.SetTokenFromMessage(aRequestOld));
|
||||
SuccessOrExit(error = iterator.Init(aRequestOld));
|
||||
@@ -686,6 +690,8 @@ Error CoapBase::PrepareNextBlockRequest(Message::BlockType aType,
|
||||
aRequest.SetMoreBlocksFlag(aMoreBlocks);
|
||||
}
|
||||
|
||||
error = metadata.AppendTo(aRequestOld);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user