@Test public void processContentType() throws Exception { ContentTypeSelector selector = mock(ContentTypeSelector.class); when(selector.determine(any(), any())).thenReturn(MediaType.TEXT_HTML); TestContentHandler handler = new TestContentHandler(null, selector, Paths.get("/root"), false); RequestHeaders req = mock(RequestHeaders.class); ResponseHeaders res = mock(ResponseHeaders.class); StaticContentHandler.processContentType(StaticContentHandler.fileName(Paths.get("/root/index.html")), req, res, selector); verify(res).contentType(MediaType.TEXT_HTML); }
static void processContentType(String filename, RequestHeaders requestHeaders, ResponseHeaders responseHeaders, ContentTypeSelector contentTypeSelector) { MediaType type = contentTypeSelector.determine(filename, requestHeaders); if (type != null) { responseHeaders.contentType(type); } }
StaticContentHandler { static void processContentType(String filename, RequestHeaders requestHeaders, ResponseHeaders responseHeaders, ContentTypeSelector contentTypeSelector) { MediaType type = contentTypeSelector.determine(filename, requestHeaders); if (type != null) { responseHeaders.contentType(type); } } }
StaticContentHandler { static void processContentType(String filename, RequestHeaders requestHeaders, ResponseHeaders responseHeaders, ContentTypeSelector contentTypeSelector) { MediaType type = contentTypeSelector.determine(filename, requestHeaders); if (type != null) { responseHeaders.contentType(type); } } StaticContentHandler(String welcomeFilename, ContentTypeSelector contentTypeSelector); }
StaticContentHandler { static void processContentType(String filename, RequestHeaders requestHeaders, ResponseHeaders responseHeaders, ContentTypeSelector contentTypeSelector) { MediaType type = contentTypeSelector.determine(filename, requestHeaders); if (type != null) { responseHeaders.contentType(type); } } StaticContentHandler(String welcomeFilename, ContentTypeSelector contentTypeSelector);  }
StaticContentHandler { static void processContentType(String filename, RequestHeaders requestHeaders, ResponseHeaders responseHeaders, ContentTypeSelector contentTypeSelector) { MediaType type = contentTypeSelector.determine(filename, requestHeaders); if (type != null) { responseHeaders.contentType(type); } } StaticContentHandler(String welcomeFilename, ContentTypeSelector contentTypeSelector);   }