public static String getHeader(Map<String, ?> args, String header, boolean required) throws RestServiceException {
    String value = null;
    if (args.containsKey(header)) {
      Object valueObj = args.get(header);
      value = valueObj != null ? valueObj.toString() : null;
      if (value == null && required) {
        throw new RestServiceException("Request has null value for header: " + header,
            RestServiceErrorCode.InvalidArgs);
      }
    } else if (required) {
      throw new RestServiceException("Request does not have required header: " + header,
          RestServiceErrorCode.MissingArgs);
    }
    return value;
  }
Gets the value of the header {@code header} in {@code args}.
@param args a map of arguments to be used to look for {@code header}.
@param header the name of the header.
@param required if {@code true}, {@link IllegalArgumentException} will be thrown if {@code header} is not present
                in {@code args}.
@return the value of {@code header} in {@code args} if it exists. If it does not exist and {@code required} is
         {@code false}, then returns null.
@throws RestServiceException if {@code required} is {@code true} and {@code header} does not exist in
                                   {@code args} or if there is more than one value for {@code header} in
                                   {@code args}.
ambry-api/src/main/java/com/github/ambry/rest/RestUtils.java