docs: @SuppressWarnings({ "PMD.NcssCount",
          "PMD.UseStringBufferForStringAppends" })
      public static boolean sendStaticContent(
              HttpRequest request, IOSubchannel channel,
              Function<String, URL> resolver, MaxAgeCalculator maxAgeCalculator) {
          String path = request.requestUri().getPath();
          URL resourceUrl = resolver.apply(path);
          ResourceInfo info;
          URLConnection resConn;
          InputStream resIn;
          try {
              if (resourceUrl == null) {
                  throw new IOException();
              }
              info = ResponseCreationSupport.resourceInfo(resourceUrl);
              if (Boolean.TRUE.equals(info.isDirectory())) {
                  throw new IOException();
              }
              resConn = resourceUrl.openConnection();
              resIn = resConn.getInputStream();
          } catch (IOException e1) {
              try {
                  if (!path.endsWith("/")) {
                      path += "/";
                  }
                  path += "index.html";
                  resourceUrl = resolver.apply(path);
                  if (resourceUrl == null) {
                      return false;
                  }
                  info = ResponseCreationSupport.resourceInfo(resourceUrl);
                  resConn = resourceUrl.openConnection();
                  resIn = resConn.getInputStream();
              } catch (IOException e2) {
                  return false;
              }
          }
          HttpResponse response = request.response().get();
          response.setField(HttpField.LAST_MODIFIED,
              Optional.ofNullable(info.getLastModifiedAt())
                  .orElseGet(() -> Instant.now()));
  
          // Get content type and derive max age
          MediaType mediaType = HttpResponse.contentType(
              ResponseCreationSupport.uriFromUrl(resourceUrl));
          setMaxAge(response,
              (maxAgeCalculator == null ? DEFAULT_MAX_AGE_CALCULATOR
                  : maxAgeCalculator).maxAge(request, mediaType));
  
          // Check if sending is really required.
          Optional<Instant> modifiedSince = request
              .findValue(HttpField.IF_MODIFIED_SINCE, Converters.DATE_TIME);
          if (modifiedSince.isPresent() && info.getLastModifiedAt() != null
              && !info.getLastModifiedAt().isAfter(modifiedSince.get())) {
              response.setStatus(HttpStatus.NOT_MODIFIED);
              channel.respond(new Response(response));
          } else {
              response.setContentType(mediaType);
              response.setStatus(HttpStatus.OK);
              channel.respond(new Response(response));
              // Start sending content (Output events as resonses)
              (new InputStreamPipeline(resIn, channel).suppressClose()).run();
          }
          return true;
      }