Skip to content

Commit

Permalink
Fix blockwise response with destination context.
Browse files Browse the repository at this point in the history
Use response destination context, if available.

Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
  • Loading branch information
boaks committed Mar 8, 2024
1 parent ad6cd37 commit 60dbf69
Showing 1 changed file with 7 additions and 4 deletions.
Expand Up @@ -708,7 +708,10 @@ public void sendResponse(final Exchange exchange, final Response response) {
if (isTransparentBlockwiseHandlingEnabled()) {

BlockOption requestBlock2 = exchange.getRequest().getOptions().getBlock2();

EndpointContext destinationContext = response.getEffectiveDestinationContext();
if (destinationContext == null) {
destinationContext = exchange.getRequest().getSourceContext();
}
if (isRandomAccess(exchange)) {

BlockOption responseBlock2 = response.getOptions().getBlock2();
Expand All @@ -722,7 +725,7 @@ public void sendResponse(final Exchange exchange, final Response response) {
tag, exchange.getRequest().getURI(), requestBlock2.getOffset(),
responseBlock2.getOffset());
responseToSend = new Response(ResponseCode.INTERNAL_SERVER_ERROR, true);
responseToSend.setDestinationContext(exchange.getRequest().getSourceContext());
responseToSend.setDestinationContext(destinationContext);
responseToSend.setType(response.getType());
responseToSend.setMID(response.getMID());
responseToSend.addMessageObservers(response.getMessageObservers());
Expand All @@ -737,7 +740,7 @@ public void sendResponse(final Exchange exchange, final Response response) {
} else if (!response.isError()) {
// peer has requested a non existing block
responseToSend = new Response(ResponseCode.BAD_OPTION, true);
responseToSend.setDestinationContext(exchange.getRequest().getSourceContext());
responseToSend.setDestinationContext(destinationContext);
responseToSend.setType(response.getType());
responseToSend.setMID(response.getMID());
responseToSend.addMessageObservers(response.getMessageObservers());
Expand All @@ -760,7 +763,7 @@ public void sendResponse(final Exchange exchange, final Response response) {
block2 = new BlockOption(preferredBlockSzx, false, 0);
}
responseToSend = status.getNextResponseBlock(block2);
responseToSend.setDestinationContext(exchange.getRequest().getSourceContext());
responseToSend.setDestinationContext(destinationContext);
if (!responseToSend.getOptions().getBlock2().isM()) {
clearBlock2Status(status);
}
Expand Down

0 comments on commit 60dbf69

Please sign in to comment.