private synchronized String getNextResponse(int index) {
    if (index >= responses.size() || globalResponseIndex >= responses.size()) {
      return null;
    }
    totalResponsesServed++;
    return forgetServedResponses ? responses.get(globalResponseIndex++) : responses.get(index);
  }
Simple local web server for testing.
jib-core/src/test/java/com/google/cloud/tools/jib/http/TestWebServer.java