public MediaType getContentType() {
        Optional<MediaType> optionalType = toContentType(Files.getFileExtension(filename));
        Optional<Charset> targetCharset = toCharset(optionalType.orElse(null));

        MediaType type = optionalType.orElse(DEFAULT_CONTENT_TYPE_WITH_CHARSET);
        if (targetCharset.isPresent() && !type.charset().toJavaUtil().equals(targetCharset)) {
            return type.withCharset(targetCharset.get());
        }

        return type;
    }
@Test
	public void should_have_charset_for_file() {
		Charset gbk = Charset.forName("gbk");
		FileContentType contentType = new FileContentType("result.response", gbk);
		assertThat(contentType.getContentType(), is(MediaType.create("text", "plain").withCharset(gbk)));
	}