public static boolean getOptionalBooleanHeader(Map<String, Object> args, String header, boolean defaultVal)
      throws RestServiceException {
    boolean booleanValue;
    String stringValue = getHeader(args, header, false);
    if (stringValue == null) {
      booleanValue = defaultVal;
    } else if ("false".equalsIgnoreCase(stringValue)) {
      booleanValue = false;
    } else if ("true".equalsIgnoreCase(stringValue)) {
      booleanValue = true;
    } else {
      throw new RestServiceException(
          header + "[" + stringValue + "] has an invalid value (allowed values: true, false)",
          RestServiceErrorCode.InvalidArgs);
    }
    return booleanValue;
  }
Gets the value of a header as a {@code boolean}.
@param args a map of arguments to be used to look for {@code header}.
@param header the name of the header.
@param defaultVal the default value for this header
@return {@code true} if the header's value is {@code "true"} (case-insensitive), or {@code false} if the header's
        value is {@code "false} (case-insensitive) or the header is not present and {@code required} is
        {@code false}.
@throws RestServiceException same as cases of {@link #getHeader(Map, String, boolean)} and if the value cannot be
                             converted to a {@code boolean}.
ambry-api/src/main/java/com/github/ambry/rest/RestUtils.java