List of usage examples for com.google.common.net MediaType withParameter
public MediaType withParameter(String attribute, String value)
From source file:org.mule.module.apikit.RestContentTypeParser.java
@Deprecated private static MediaType getMediaType(MimeType mimeType) { MediaType mediaType = MediaType.parse(mimeType.getType()); return mediaType.withParameter("q", "1"); }
From source file:com.tinspx.util.net.MultipartBody.java
private MultipartBody setContentType(@NonNull MediaType contentType, @Nullable String boundary, boolean init) { if (boundary != null) { contentType = contentType.withParameter(BOUNDARY, boundary); } else {/* w w w. j a va2 s.c o m*/ List<String> b = contentType.parameters().get(BOUNDARY); if (b.isEmpty()) { boundary = init ? generateBoundary() : this.boundary; contentType = contentType.withParameter(BOUNDARY, boundary); } else if (b.size() > 1) { throw new IllegalArgumentException( String.format("type (%s) has multiple boundary parameters", contentType)); } else { boundary = b.get(0); } } checkBoundary(boundary); boundaryBytes = CharUtils.encodeAscii(boundary); this.boundary = boundary; headers.replaceValues(HttpHeaders.CONTENT_TYPE, Collections.singleton(contentType.toString())); type = contentType; valid = false; return this; }