Skip to content
This repository has been archived by the owner on Aug 23, 2020. It is now read-only.

Commit

Permalink
added X-IOTA-API-Version header check
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul D Handy committed Oct 23, 2017
1 parent d7679b4 commit 787cdfc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/java/com/iota/iri/service/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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": {
Expand Down

0 comments on commit 787cdfc

Please sign in to comment.