static void checkCustomHeader()

in iep-ses/src/main/java/com/netflix/iep/ses/EmailHeader.java [46:66]


  static void checkCustomHeader(String header) {
    if (DENYLIST.contains(header.toLowerCase(Locale.US))) {
      throw new IllegalArgumentException("'" + header + "' cannot be used as a custom header, " +
          "use the appropriate method on the builder");
    }

    // Check that only allowed characters are used in the header
    for (int i = 0; i < header.length(); ++i) {
      if (!isAllowedInFieldName(header.charAt(i))) {
        throw new IllegalArgumentException("'" + header + "' contains an invalid character: '" +
            header.charAt(i) + "'");
      }
    }

    // Check max length of header, lines should be 78 characters or less including CRLF. Since
    // the header cannot be folded this means max length of 74 (78 - len(': ') - len(CRLF)).
    // https://tools.ietf.org/html/rfc5322#section-2.2.3
    if (header.length() > 74) {
      throw new IllegalArgumentException("'" + header + "' header exceeds max length of 74");
    }
  }