@Override public ContentType getContentType() { if(headers != null) { return HttpUtil.getContentType(headers); } return null; }
public static ContentType getContentType(MultiValueMap<String, String> headers) { for(String key: headers.keySet()) { if("content-type".equalsIgnoreCase(key.trim())) { return getContentType(headers.get(key).iterator().next()); } } return null; }
/** * Test of getContentType method, of class HttpUtil. */ @Test public void testGetContentType_String() { System.out.println("getContentType"); String header = "application/vnd.mnet.staticwebspaces+xml;version=1;charset=UTF-8"; ContentType expResult = new ContentTypeBean("application/vnd.mnet.staticwebspaces+xml", Charsets.UTF_8); ContentType result = HttpUtil.getContentType(header); assertEquals(expResult, result); } }