@Test public void getResponseData_contentTypeExMachina() throws Exception { Charset exMachinaCharset = UTF_8; SstoehrHarBridge bridge = new SstoehrHarBridge(exMachinaCharset); ParsedRequest request = ParsedRequest.inMemory(io.github.mike10004.vhs.harbridge.HttpMethod.GET, URI.create("http: MediaType entryResponseContentType = MediaType.PLAIN_TEXT_UTF_8.withoutParameters(); HarEntry entry = createHarEntry(request.url, entryResponseContentType, "foo", 3); HarResponseData responseData = bridge.getResponseData(request, entry, HarResponseEncoding.unencoded()); MediaType expectedResponseContentType = entryResponseContentType.withCharset(exMachinaCharset); MediaType responseDataContentType = responseData.getContentType(); assertEquals("responseDataContentType", expectedResponseContentType, responseDataContentType); String responseDataContentTypeHeaderValue = responseData.getFirstHeaderValue(HttpHeaders.CONTENT_TYPE); assertNotNull("expect responseData to contain content-type header", responseDataContentTypeHeaderValue); assertEquals("responseData content-type header value", expectedResponseContentType, MediaType.parse(responseDataContentTypeHeaderValue)); }
@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; }