protected Response.ResponseType getWebApplicationServiceResponseType(final WebApplicationService finalService) {
        val request = HttpRequestUtils.getHttpServletRequestFromRequestAttributes();
        val methodRequest = Optional.ofNullable(request)
            .map(httpServletRequest -> httpServletRequest.getParameter(CasProtocolConstants.PARAMETER_METHOD))
            .or(() -> CollectionUtils.firstElement(finalService.getAttributes().get(CasProtocolConstants.PARAMETER_METHOD)).map(Object::toString))
            .filter(StringUtils::isNotBlank)
            .orElse(null);
        val func = FunctionUtils.doIf(StringUtils::isBlank,
            __ -> {
                val registeredService = servicesManager.findServiceBy(finalService);
                return registeredService instanceof final CasModelRegisteredService casService ? casService.getResponseType() : null;
            },
            __ -> methodRequest);
        val method = func.apply(methodRequest);
        if (StringUtils.isBlank(method) || !EnumUtils.isValidEnum(Response.ResponseType.class, method.toUpperCase(Locale.ENGLISH))) {
            return Response.ResponseType.REDIRECT;
        }
        return Response.ResponseType.valueOf(method.toUpperCase(Locale.ENGLISH));
    }
Abstract response builder that provides wrappers for building
post and redirect responses.

@author Misagh Moayyed
@since 4.2
core/cas-server-core-services-authentication/src/main/java/org/apereo/cas/authentication/principal/AbstractWebApplicationServiceResponseBuilder.java