/** * Returns a new request body that transmits {@code content}. If {@code * contentType} lacks a charset, this will use UTF-8. */ public static Body create(MediaType contentType, String content) { contentType = contentType.charset() != null ? contentType : MediaType.parse(contentType + "; charset=utf-8"); try { byte[] bytes = content.getBytes(contentType.charset().name()); return create(contentType, bytes); } catch (UnsupportedEncodingException e) { throw new AssertionError(); } }
/** * Returns a new request body that transmits {@code content}. If {@code * contentType} lacks a charset, this will use UTF-8. */ public static Body create(MediaType contentType, String content) { contentType = contentType.charset() != null ? contentType : MediaType.parse(contentType + "; charset=utf-8"); try { byte[] bytes = content.getBytes(contentType.charset().name()); return create(contentType, bytes); } catch (UnsupportedEncodingException e) { throw new AssertionError(); } }