code: public static MessageProtocol fromContentTypeHeader(Optional<String> contentType) {
          return contentType.map(ct -> {
              String[] parts = ct.split(";");
              String justContentType = parts[0];
              Optional<String> charset = Optional.empty();
              for (int i = 1; i < parts.length; i++) {
                  String toTest = parts[i].trim();
                  if (toTest.startsWith("charset=")) {
                      charset = Optional.of(toTest.split("=", 2)[1]);
                      break;
                  }
              }
              return new MessageProtocol(Optional.of(justContentType), charset, Optional.empty());
          }).orElse(new MessageProtocol());
      }
docs: Parse a message protocol from a content type header, if defined.
  
  @param contentType The content type header to parse.
  @return The parsed message protocol.