private static ContentType getContentType(String mediaType, Charset charset) { if (!HttpUtils.isPrintable(mediaType)) { try { return ContentType.create(mediaType); } catch (Exception e) { return null; } } Map<String, String> map = HttpUtils.parseContentTypeParams(mediaType); if (map != null) { String cs = map.get(HttpUtils.CHARSET); if (cs != null) { charset = Charset.forName(cs); map.remove(HttpUtils.CHARSET); } } ContentType ct = ContentType.parse(mediaType).withCharset(charset); if (map != null) { for (Map.Entry<String, String> entry : map.entrySet()) { ct = ct.withParameters(new BasicNameValuePair(entry.getKey(), entry.getValue())); } } return ct; }
contentType.withParameters(params) : ContentType.create("multipart/" + DEFAULT_SUBTYPE, params); final List<FormBodyPart> bodyPartsCopy = bodyParts != null ? new ArrayList<FormBodyPart>(bodyParts) :
contentType.withParameters(params) : ContentType.create("multipart/" + DEFAULT_SUBTYPE, params); final List<FormBodyPart> bodyPartsCopy = bodyParts != null ? new ArrayList<FormBodyPart>(bodyParts) :
String boundary = HttpUtils.generateMimeBoundaryMarker(); String text = HttpUtils.multiPartToString(items, boundary); ContentType ct = ContentType.parse(mediaType).withParameters(new BasicNameValuePair("boundary", boundary)); return new StringEntity(text, ct); } else {