private long getLongPollingTimeoutMillis(HttpRequest req) {
        if (!isLongPollingEnabled()) {
            return 0;
        }

        final String prefer = req.headers().get(HttpHeaderNames.PREFER);
        if (prefer == null) {
            return 0;
        }

        // TODO(trustin): Optimize this once https://github.com/line/armeria/issues/1835 is resolved.
        final LongHolder timeoutMillisHolder = new LongHolder();
        try {
            ArmeriaHttpUtil.parseDirectives(prefer, (name, value) -> {
                if ("wait".equals(name)) {
                    timeoutMillisHolder.value = TimeUnit.SECONDS.toMillis(Long.parseLong(value));
                }
            });
        } catch (NumberFormatException ignored) {
            // Malformed "wait" value.
            throw HttpStatusException.of(HttpStatus.BAD_REQUEST);
        }

        if (timeoutMillisHolder.value <= 0) {
            throw HttpStatusException.of(HttpStatus.BAD_REQUEST);
        }

        final double multiplier;
        if (longPollingTimeoutJitterRate > 0) {
            multiplier = 1.0 - ThreadLocalRandom.current().nextDouble(longPollingTimeoutJitterRate);
        } else {
            multiplier = 1;
        }
        return (long) (Math.min(timeoutMillisHolder.value, maxLongPollingTimeoutMillis) * multiplier);
    }
Returns a new builder which builds a new {@link HealthCheckService}.
core/src/main/java/com/linecorp/armeria/server/healthcheck/HealthCheckService.java