commons/http/src/main/java/org/ldp4j/http/MediaTypes.java
public static String toHeader(final MediaType mediaType) {
		requireNonNull(mediaType,REFERENCE_MEDIA_TYPE_CANNOT_BE_NULL);
		final StringBuilder builder=
			new StringBuilder().
				append(mediaType.type().toLowerCase(Locale.ENGLISH)).
				append('/').
				append(mediaType.subType().toLowerCase(Locale.ENGLISH));
		final String suffix=mediaType.suffix();
		if(suffix!=null) {
			builder.append('+').append(suffix.toLowerCase(Locale.ENGLISH));
		}
		final Charset charset=mediaType.charset();
		if(charset!=null) {
			builder.append(";charset=").append(charset.name().toLowerCase(Locale.ENGLISH));
		}
		for(Entry<String,String> entry:mediaType.parameters().entrySet()) {
			final String key=entry.getKey();
			if(isStandardParameter(key)) {
				continue;
			}
			builder.append(';').append(key.toLowerCase(Locale.ENGLISH)).append('=').append(entry.getValue());
		}
		return builder.toString();
	}
public static String toHeader(final MediaType mediaType) {
		requireNonNull(mediaType,REFERENCE_MEDIA_TYPE_CANNOT_BE_NULL);
		final StringBuilder builder=
			new StringBuilder().
				append(mediaType.type().toLowerCase(Locale.ENGLISH)).
				append('/').
				append(mediaType.subType().toLowerCase(Locale.ENGLISH));
		final String suffix=mediaType.suffix();
		if(suffix!=null) {
			builder.append('+').append(suffix.toLowerCase(Locale.ENGLISH));
		}
		final Charset charset=mediaType.charset();
		if(charset!=null) {
			builder.append(";charset=").append(charset.name().toLowerCase(Locale.ENGLISH));
		}
		for(Entry<String,String> entry:mediaType.parameters().entrySet()) {
			final String key=entry.getKey();
			if(isStandardParameter(key)) {
				continue;
			}
			builder.append(';').append(key.toLowerCase(Locale.ENGLISH)).append('=').append(entry.getValue());
		}
		return builder.toString();
	}
public static String toHeader ( final MediaType mediaType ) { requireNonNull ( mediaType , REFERENCE_MEDIA_TYPE_CANNOT_BE_NULL ) ; final StringBuilder builder = new StringBuilder ( ) . append ( mediaType . type ( ) . toLowerCase ( Locale . ENGLISH ) ) . append ( ' ' ) . append ( mediaType . subType ( ) . toLowerCase ( Locale . ENGLISH ) ) ; final String suffix = mediaType . suffix ( ) ; if ( suffix != null ) { builder . append ( ' ' ) . append ( suffix . toLowerCase ( Locale . ENGLISH ) ) ; } final Charset charset = mediaType . charset ( ) ; if ( charset != null ) { builder . append ( ";charset=" ) . append ( charset . name ( ) . toLowerCase ( Locale . ENGLISH ) ) ; } for ( Entry < String , String > entry : mediaType . parameters ( ) . entrySet ( ) ) { final String key = entry . getKey ( ) ; if ( isStandardParameter ( key ) ) { continue ; } builder . append ( ' ' ) . append ( key . toLowerCase ( Locale . ENGLISH ) ) . append ( ' ' ) . append ( entry . getValue ( ) ) ; } return builder . toString ( ) ; }
Format the media type in a HTTP-header compliant manner using preferred
format.

@param mediaType
the media type to format
@return the compliant representation of the media type
@see <a href="https://tools.ietf.org/html/rfc7231#section-3.1.1.1">[RFC
7231] Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content,
section 3.1.1.1</a>
Format the media type in a HTTP - header compliant manner using preferred format .