Parse the character encoding from the specified content type header. If the content type is null, or there is no explicit character encoding, null is returned. @param contentType a content type header
(String contentType)
| 1338 | * @param contentType a content type header |
| 1339 | */ |
| 1340 | private static String getCharsetFromContentType(String contentType) { |
| 1341 | |
| 1342 | if (contentType == null) { |
| 1343 | return null; |
| 1344 | } |
| 1345 | |
| 1346 | MediaType mediaType = null; |
| 1347 | try { |
| 1348 | mediaType = MediaType.parseMediaType(new StringReader(contentType)); |
| 1349 | } catch (IOException ioe) { |
| 1350 | // Ignore - null test below handles this |
| 1351 | } |
| 1352 | if (mediaType != null) { |
| 1353 | return mediaType.getCharset(); |
| 1354 | } |
| 1355 | |
| 1356 | return null; |
| 1357 | } |
| 1358 | } |
no test coverage detected