WARCRecord { public static String extractHTTPHeaderContentType(String httpHeaderText) throws IOException { if (httpHeaderText == null) { throw new IOException("httpHeaderText parameter is null"); } Matcher matcher = CONTENT_TYPE_PATTERN.matcher(httpHeaderText); if (matcher.find()) { return matcher.group(1).toLowerCase(); } return null; } WARCRecord(DataInput in);  WARCRecord(WARCRecord other); boolean isContentApplicationHttpResponse(); String getHTTPHeaders(); Header getHeader(); byte[] getContent(); void write(DataOutput out); @Override String toString(); void setContent(String newContent); static String extractHTTPHeaderContentType(String httpHeaderText); static String extractHTTPHeaderCharset(String httpHeaderText); static final String WARC_VERSION; }
@Test public void testExtractHTTPHeaderContentType() throws Exception { String httpHeaders = "HTTP/1.1 200 OK\n" + "Date: Sun, 05 Jul 2015 17:30:02 GMT\n" + "Server: Apache/2.2.29 (Unix) FrontPage/5.0.2.2635\n" + "X-Powered-By: PHP/5.3.29-pl0-gentoo\n" + "X-Pingback: http: + "Link: <http: + "Connection: close\n" + "Content-Type: text/html; charset=UTF-8\n"; assertEquals("text/html", WARCRecord.extractHTTPHeaderContentType(httpHeaders)); httpHeaders = "HTTP/1.1 200 OK\n" + "Date: Sun, 05 Jul 2015 17:30:02 GMT\n" + "Content-Type: application/xhtml+xml\n" + "Server: Apache/2.2.29 (Unix) FrontPage/5.0.2.2635\n"; assertEquals("application/xhtml+xml", WARCRecord.extractHTTPHeaderContentType(httpHeaders)); httpHeaders = "HTTP/1.1 200 OK\n" + "Date: Sun, 05 Jul 2015 17:30:02 GMT\n" + "Content-Type: application/wordperfect5.1;\n" + "Server: Apache/2.2.29 (Unix) FrontPage/5.0.2.2635\n"; assertEquals("application/wordperfect5.1", WARCRecord.extractHTTPHeaderContentType(httpHeaders)); }