class RequestPropertyFilter {

    public static FilterResult filterProperty(HttpServerRequest request, String filterPropertyKey, String filterPropertyValue, boolean reject) {

        CaseInsensitiveHeaders headers = new CaseInsensitiveHeaders();
        headers.setAll(request.headers());

        if (URL.equals(filterPropertyKey)) {
            boolean matches = filterRequestURL(request, filterPropertyValue);
            FilterResult result = rejectIfNeeded(reject, matches);
            logFilterResult(request, filterPropertyKey, filterPropertyValue, result);
            return result;
        }
        if (METHOD.equals(filterPropertyKey)) {
            boolean matches = filterRequestMethod(request, filterPropertyValue);
            FilterResult result = rejectIfNeeded(reject, matches);
            logFilterResult(request, filterPropertyKey, filterPropertyValue, result);
            return result;
        }
        if (headers.names().contains(filterPropertyKey) && headers.get(filterPropertyKey).equalsIgnoreCase(filterPropertyValue)) {
            FilterResult result = reject ? FilterResult.REJECT : FilterResult.FILTER;
            logFilterResult(request, filterPropertyKey, filterPropertyValue, result);
            return result;
        }
        logFilterResult(request, filterPropertyKey, filterPropertyValue, FilterResult.REJECT, true);
        return FilterResult.REJECT;
    }

}