private static void earlyBlock2Negotiation(final Exchange exchange, final Request request) { // Call this method when a request has completely arrived (might have // been sent in one piece without blockwise). BlockOption block2 = request.getOptions().getBlock2(); if (block2 != null) { BlockwiseStatus status2 = new BlockwiseStatus(request.getOptions().getContentFormat(), block2.getNum(), block2.getSzx()); LOGGER.log(Level.FINE, "Request with early block negotiation {0}. Create and set new Block2 status: {1}", new Object[]{block2, status2}); exchange.setResponseBlockStatus(status2); } }
private void earlyBlock2Negotiation(final Exchange exchange, final Request request) { // Call this method when a request has completely arrived (might have // been sent in one piece without blockwise). if (request.getOptions().hasBlock2()) { BlockOption block2 = request.getOptions().getBlock2(); BlockwiseStatus status2 = new BlockwiseStatus(request.getOptions().getContentFormat(), block2.getNum(), block2.getSzx()); LOGGER.fine("Request with early block negotiation "+block2+". Create and set new Block2 status: "+status2); exchange.setResponseBlockStatus(status2); } }
@Override protected boolean checkResponse(Request request, Response response) { boolean success = response.getOptions().hasBlock2(); if (!success) { System.out.println("FAIL: no Block2 option"); } else { int maxNUM = response.getOptions().getBlock2().getNum(); success &= checkType(Type.ACK, response.getType()); success &= checkInt(EXPECTED_RESPONSE_CODE.value, response.getCode().value, "code"); success &= checkOption(new BlockOption(PlugtestChecker.PLUGTEST_BLOCK_SZX, false, maxNUM), response.getOptions().getBlock2(), "Block2"); success &= hasNonEmptyPalyoad(response); success &= hasContentType(response); } return success; } }
@Override protected boolean checkResponse(Request request, Response response) { boolean success = response.getOptions().hasBlock2(); if (!success) { System.out.println("FAIL: no Block2 option"); } else { int maxNUM = response.getOptions().getBlock2().getNum(); success &= checkType(Type.ACK, response.getType()); success &= checkInt(EXPECTED_RESPONSE_CODE.value, response.getCode().value, "code"); success &= checkOption(new BlockOption(EXPECTED_BLOCK_SIZE, false, maxNUM), response.getOptions().getBlock2(), "Block2"); success &= hasNonEmptyPalyoad(response); success &= hasContentType(response); } return success; } }
options.add(new Option(OptionNumberRegistry.BLOCK1, getBlock1().getValue())); if (hasBlock2()) options.add(new Option(OptionNumberRegistry.BLOCK2, getBlock2().getValue())); if (hasSize1()) options.add(new Option(OptionNumberRegistry.SIZE1, getSize1()));
options.add(new Option(OptionNumberRegistry.BLOCK1, getBlock1().getValue())); if (hasBlock2()) options.add(new Option(OptionNumberRegistry.BLOCK2, getBlock2().getValue())); if (hasSize1()) options.add(new Option(OptionNumberRegistry.SIZE1, getSize1()));
protected final void appendRequestDetails(final Request request) { if (request.isCanceled()) { buffer.append("CANCELED "); } buffer.append(request.getType()).append(" [MID=").append(request.getMID()) .append(", T=").append(request.getTokenString()).append("], ") .append(request.getCode()).append(", /").append(request.getOptions().getUriPathString()); appendBlockOption(1, request.getOptions().getBlock1()); appendBlockOption(2, request.getOptions().getBlock2()); appendObserveOption(request.getOptions()); appendSize1(request.getOptions()); appendEtags(request.getOptions()); }
protected final void appendResponseDetails(final Response response) { if (response.isCanceled()) { buffer.append("CANCELED "); } buffer.append(response.getType()).append(" [MID=").append(response.getMID()) .append(", T=").append(response.getTokenString()).append("], ") .append(response.getCode()); appendBlockOption(1, response.getOptions().getBlock1()); appendBlockOption(2, response.getOptions().getBlock2()); appendObserveOption(response.getOptions()); appendSize1(response.getOptions()); appendSize2(response.getOptions()); appendEtags(response.getOptions()); }
@Override public void sendRequest(final Exchange exchange, final Request request) { if (request.getOptions().hasBlock2() && request.getOptions().getBlock2().getNum() > 0) { // This is the case if the user has explicitly added a block option // for random access. // Note: We do not regard it as random access when the block num is // 0. This is because the user might just want to do early block // size negotiation but actually wants to receive all blocks. LOGGER.fine("Request carries explicit defined block2 option: create random access blockwise status"); BlockwiseStatus status = new BlockwiseStatus(request.getOptions().getContentFormat()); BlockOption block2 = request.getOptions().getBlock2(); status.setCurrentSzx(block2.getSzx()); status.setCurrentNum(block2.getNum()); status.setRandomAccess(true); exchange.setResponseBlockStatus(status); super.sendRequest(exchange, request); } else if (requiresBlockwise(request)) { // This must be a large POST or PUT request LOGGER.fine("Request payload "+request.getPayloadSize()+"/"+max_message_size+" requires Blockwise"); BlockwiseStatus status = findRequestBlockStatus(exchange, request); Request block = getNextRequestBlock(request, status); exchange.setRequestBlockStatus(status); exchange.setCurrentRequest(block); super.sendRequest(exchange, block); } else { exchange.setCurrentRequest(request); super.sendRequest(exchange, request); } }
block = response.getOptions().getBlock2(); if (block != null) { handleBlock2Response(exchange, response, block);
BlockOption block2 = request.getOptions().getBlock2(); Response response = exchange.getResponse(); BlockwiseStatus status = findResponseBlockStatus(exchange, response);
@Override public void sendRequest(final Exchange exchange, final Request request) { BlockOption block2 = request.getOptions().getBlock2(); if (block2 != null && block2.getNum() > 0) { // This is the case if the user has explicitly added a block option // for random access. // Note: We do not regard it as random access when the block num is // 0. This is because the user might just want to do early block // size negotiation but actually wants to receive all blocks. LOGGER.fine("request contains block2 option, creating random-access blockwise status"); BlockwiseStatus status = new BlockwiseStatus(getSizeForSzx(block2.getSzx()), request.getOptions().getContentFormat()); status.setCurrentSzx(block2.getSzx()); status.setCurrentNum(block2.getNum()); status.setRandomAccess(true); exchange.setResponseBlockStatus(status); lower().sendRequest(exchange, request); } else if (requiresBlockwise(request)) { // This must be a large POST or PUT request startBlockwiseUpload(exchange, request); } else { // no blockwise transfer required exchange.setCurrentRequest(request); lower().sendRequest(exchange, request); } }
public void check(Message message) { assertTrue("No Block2 option:", message.getOptions().hasBlock2()); BlockOption block2 = message.getOptions().getBlock2(); assertEquals("Wrong Block2 num:", num, block2.getNum()); assertEquals("Wrong Block2 m:", m, block2.isM()); assertEquals("Wrong Block2 size:", size, block2.getSize()); print("Correct Block2 option: " + block2); }
BlockOption block2 = request.getOptions().getBlock2(); Response response = exchange.getResponse(); BlockwiseStatus status = findResponseBlockStatus(exchange, response);
BlockOption block2 = response.getOptions().getBlock2(); BlockwiseStatus status = findResponseBlockStatus(exchange, response);