Skip to content

Commit

Permalink
Remove block1 in error response.
Browse files Browse the repository at this point in the history
Fixes: issue eclipse-californium#1937

Signed-off-by: Achim Kraus <[email protected]>
  • Loading branch information
Achim Kraus committed Mar 11, 2022
1 parent a893cae commit e8648a0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -568,12 +568,28 @@ private void handleInboundBlockwiseUpload(final Exchange exchange, final Request
}
}

private void sendBlock1ErrorResponse(KeyUri key, Block1BlockwiseStatus status, Exchange exchange, Request request,
/**
* Send block1 error response.
*
* Note: before version 2.7.1 a block1 option was used in the response.
* According <a href="https://github.com/core-wg/corrclar/issues/21" target=
* "_blank">CorrClar - RFC7959 - Block1 Option in Error Response 4.08
* (Request Entity Incomplete)</a>, it seems to be not intended. If your
* device requires that, you may override this method and respond with an
* block1 option.
*
* @param key URI key
* @param status blockwise status
* @param exchange exchange
* @param request current request
* @param errorCode error code for the error response
* @param message textual message for the error response
* @since 2.7.1 no block1 option is used in the response
*/
protected void sendBlock1ErrorResponse(KeyUri key, Block1BlockwiseStatus status, Exchange exchange, Request request,
ResponseCode errorCode, String message) {

BlockOption block1 = request.getOptions().getBlock1();
Response error = Response.createResponse(request, errorCode);
error.getOptions().setBlock1(block1.getSzx(), block1.isM(), block1.getNum());
error.setPayload(message);
clearBlock1Status(key, status);
exchange.setCurrentResponse(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ public void testRandomAccessPUTAttemp() throws Exception {
Token tok = generateNextToken();

client.sendRequest(CON, PUT, tok, ++mid).path(RESOURCE_PATH).block1(2, true, 64).payload(reqtPayload.substring(2*64, 3*64)).go();
client.expectResponse(ACK, REQUEST_ENTITY_INCOMPLETE, tok, mid).block1(2, true, 64).go();
client.expectResponse(ACK, REQUEST_ENTITY_INCOMPLETE, tok, mid).go();
}

@Test
Expand Down

0 comments on commit e8648a0

Please sign in to comment.