@Test public void getContentType_absent() throws Exception { HarBridge<HarEntry> bridge = new SstoehrHarBridge(); HarEntry entry = new HarEntry(); HarResponse response = new HarResponse(); HarContent content = new HarContent(); response.setContent(content); entry.setResponse(response); ParsedRequest request = ParsedRequest.inMemory(io.github.mike10004.vhs.harbridge.HttpMethod.GET, URI.create("https: HarResponseData actual = bridge.getResponseData(request, entry, HarResponseEncoding.unencoded()); assertEquals("body", 0, actual.getBody().read().length); assertEquals("content-type", HarBridge.getContentTypeDefaultValue(), actual.getContentType()); assertEquals("", 0, actual.headers().size()); }
@Override public HarResponseData getResponseData(ParsedRequest request, HarEntry entry, HarResponseEncoding encoding) throws IOException { TypedContent contentPackage = getResponseBody(entry); List<Map.Entry<String, String>> headers = getResponseHeaders(entry); HarResponseData underlying = HarResponseData.of(headers, contentPackage.getContentType(), contentPackage.asByteSource()); underlying = underlying.transformer() .replaceContentType(contentPackage.getContentType()) .replaceHeader(HttpHeaders.CONTENT_ENCODING, HttpContentCodecs.CONTENT_ENCODING_IDENTITY) .transform(); return encoding.transformUnencoded(underlying); }
SstoehrHarBridge implements HarBridge<HarEntry> { @Override public HarResponseData getResponseData(ParsedRequest request, HarEntry entry, HarResponseEncoding encoding) throws IOException { TypedContent contentPackage = getResponseBody(entry); List<Map.Entry<String, String>> headers = getResponseHeaders(entry); HarResponseData underlying = HarResponseData.of(headers, contentPackage.getContentType(), contentPackage.asByteSource()); underlying = underlying.transformer() .replaceContentType(contentPackage.getContentType()) .replaceHeader(HttpHeaders.CONTENT_ENCODING, HttpContentCodecs.CONTENT_ENCODING_IDENTITY) .transform(); return encoding.transformUnencoded(underlying); } }
SstoehrHarBridge implements HarBridge<HarEntry> { @Override public HarResponseData getResponseData(ParsedRequest request, HarEntry entry, HarResponseEncoding encoding) throws IOException { TypedContent contentPackage = getResponseBody(entry); List<Map.Entry<String, String>> headers = getResponseHeaders(entry); HarResponseData underlying = HarResponseData.of(headers, contentPackage.getContentType(), contentPackage.asByteSource()); underlying = underlying.transformer() .replaceContentType(contentPackage.getContentType()) .replaceHeader(HttpHeaders.CONTENT_ENCODING, HttpContentCodecs.CONTENT_ENCODING_IDENTITY) .transform(); return encoding.transformUnencoded(underlying); } SstoehrHarBridge();  SstoehrHarBridge(Charset exMachinaCharset); }
SstoehrHarBridge implements HarBridge<HarEntry> { @Override public HarResponseData getResponseData(ParsedRequest request, HarEntry entry, HarResponseEncoding encoding) throws IOException { TypedContent contentPackage = getResponseBody(entry); List<Map.Entry<String, String>> headers = getResponseHeaders(entry); HarResponseData underlying = HarResponseData.of(headers, contentPackage.getContentType(), contentPackage.asByteSource()); underlying = underlying.transformer() .replaceContentType(contentPackage.getContentType()) .replaceHeader(HttpHeaders.CONTENT_ENCODING, HttpContentCodecs.CONTENT_ENCODING_IDENTITY) .transform(); return encoding.transformUnencoded(underlying); } SstoehrHarBridge();  SstoehrHarBridge(Charset exMachinaCharset); @Override String getRequestMethod(HarEntry entry); @Override String getRequestUrl(HarEntry entry); @Override Stream<Map.Entry<String, String>> getRequestHeaders(HarEntry entry); @Nullable @Override ByteSource getRequestPostData(HarEntry entry); @Override HarResponseData getResponseData(ParsedRequest request, HarEntry entry, HarResponseEncoding encoding); @Override int getResponseStatus(HarEntry entry); }
SstoehrHarBridge implements HarBridge<HarEntry> { @Override public HarResponseData getResponseData(ParsedRequest request, HarEntry entry, HarResponseEncoding encoding) throws IOException { TypedContent contentPackage = getResponseBody(entry); List<Map.Entry<String, String>> headers = getResponseHeaders(entry); HarResponseData underlying = HarResponseData.of(headers, contentPackage.getContentType(), contentPackage.asByteSource()); underlying = underlying.transformer() .replaceContentType(contentPackage.getContentType()) .replaceHeader(HttpHeaders.CONTENT_ENCODING, HttpContentCodecs.CONTENT_ENCODING_IDENTITY) .transform(); return encoding.transformUnencoded(underlying); } SstoehrHarBridge();  SstoehrHarBridge(Charset exMachinaCharset); @Override String getRequestMethod(HarEntry entry); @Override String getRequestUrl(HarEntry entry); @Override Stream<Map.Entry<String, String>> getRequestHeaders(HarEntry entry); @Nullable @Override ByteSource getRequestPostData(HarEntry entry); @Override HarResponseData getResponseData(ParsedRequest request, HarEntry entry, HarResponseEncoding encoding); @Override int getResponseStatus(HarEntry entry); static final Charset DEFAULT_EX_MACHINA_CHARSET; }