diff --git a/src/main/java/com/iota/iri/service/API.java b/src/main/java/com/iota/iri/service/API.java index 675615b394..74278a28e8 100644 --- a/src/main/java/com/iota/iri/service/API.java +++ b/src/main/java/com/iota/iri/service/API.java @@ -155,7 +155,12 @@ private void processRequest(final HttpServerExchange exchange) throws IOExceptio final long beginningTime = System.currentTimeMillis(); final String body = IOUtils.toString(cis, StandardCharsets.UTF_8); - final AbstractResponse response = process(body, exchange.getSourceAddress()); + final AbstractResponse response; + if (exchange.getRequestHeaders().contains("X-IOTA-API-Version")) { + response = process(body, exchange.getSourceAddress()); + } else { + response = ErrorResponse.create("Invalid API Version"); + } sendResponse(exchange, response, beginningTime); } @@ -180,9 +185,6 @@ private AbstractResponse process(final String requestString, InetSocketAddress s log.debug("# {} -> Requesting command '{}'", counter.incrementAndGet(), command); - if (!request.containsKey("apiVersion")) { - return ErrorResponse.create("Invalid API Version"); - } switch (command) { case "addNeighbors": {