@Test public void constructHeaders() throws Exception { MappingEntryMatcher m = new MappingEntryMatcher(ImmutableList.of(), temporaryFolder.getRoot().toPath()); Random random = new Random(MappingEntryMatcherTest.class.getName().hashCode()); int length = 1024; byte[] bytes = new byte[length]; random.nextBytes(bytes); File file = temporaryFolder.newFile(); Multimap<String, String> rawHeaders = m.constructHeaders(file, MediaType.OCTET_STREAM); NameValuePairList.StringMapEntryList headers = NameValuePairList.StringMapEntryList.caseInsensitive(rawHeaders.entries()); assertEquals("num content-length headers", 1, headers.streamValues(HttpHeaders.CONTENT_LENGTH).count()); assertEquals("num content-type headers", 1, headers.streamValues(HttpHeaders.CONTENT_TYPE).count()); }
protected Multimap<String, String> constructHeaders(File file, MediaType contentType) { Multimap<String, String> headers = ArrayListMultimap.create(); headers.put(HttpHeaders.CONTENT_TYPE, contentType.toString()); readFileAttributes(file).forEach(headers::put); return headers; }
MappingEntryMatcher implements EntryMatcher<S> { protected Multimap<String, String> constructHeaders(File file, MediaType contentType) { Multimap<String, String> headers = ArrayListMultimap.create(); headers.put(HttpHeaders.CONTENT_TYPE, contentType.toString()); readFileAttributes(file).forEach(headers::put); return headers; } }
MappingEntryMatcher implements EntryMatcher<S> { protected Multimap<String, String> constructHeaders(File file, MediaType contentType) { Multimap<String, String> headers = ArrayListMultimap.create(); headers.put(HttpHeaders.CONTENT_TYPE, contentType.toString()); readFileAttributes(file).forEach(headers::put); return headers; } MappingEntryMatcher(Iterable<Mapping> mappings, Path fileResolutionRoot); }
MappingEntryMatcher implements EntryMatcher<S> { protected Multimap<String, String> constructHeaders(File file, MediaType contentType) { Multimap<String, String> headers = ArrayListMultimap.create(); headers.put(HttpHeaders.CONTENT_TYPE, contentType.toString()); readFileAttributes(file).forEach(headers::put); return headers; } MappingEntryMatcher(Iterable<Mapping> mappings, Path fileResolutionRoot); @Nullable @Override HttpRespondable findTopEntry(S state, ParsedRequest request); }
MappingEntryMatcher implements EntryMatcher<S> { protected Multimap<String, String> constructHeaders(File file, MediaType contentType) { Multimap<String, String> headers = ArrayListMultimap.create(); headers.put(HttpHeaders.CONTENT_TYPE, contentType.toString()); readFileAttributes(file).forEach(headers::put); return headers; } MappingEntryMatcher(Iterable<Mapping> mappings, Path fileResolutionRoot); @Nullable @Override HttpRespondable findTopEntry(S state, ParsedRequest request);  }