@Test public void testGzippedHtml() throws Exception { String json = Resources.toString(getClass().getResource("/gzipped-response.json"), UTF_8); JsonObject response = new JsonParser().parse(json).getAsJsonObject(); JsonObject content = response.getAsJsonObject("content"); String contentEncodingHeaderValue = HarBridgeTests.getFirstHeaderValueFromNameValuePairs(response.getAsJsonArray("headers"), HttpHeaders.CONTENT_ENCODING); String text = content.get("text").getAsString(); byte[] data = Hars.translateResponseContent(content.get("mimeType").getAsString(), text, response.get("bodySize").getAsLong(), content.get("size").getAsLong(), contentEncodingHeaderValue, null, null, UTF_8).asByteSource().read(); String decompressedText = new String(data, UTF_8); assertEquals("text", text, decompressedText); }
public static TypedContent translateResponseContent( String contentType, @Nullable String text, @Nullable Long bodySize, @Nullable Long contentSize, @Nullable String contentEncodingHeaderValue, @Nullable String harContentEncoding, @SuppressWarnings("unused") @Nullable String comment, Charset defaultCharset) { return getUncompressedContent(contentType, text, bodySize, contentSize, contentEncodingHeaderValue, harContentEncoding, comment, defaultCharset); }
Hars { public static TypedContent translateResponseContent( String contentType, @Nullable String text, @Nullable Long bodySize, @Nullable Long contentSize, @Nullable String contentEncodingHeaderValue, @Nullable String harContentEncoding, @SuppressWarnings("unused") @Nullable String comment, Charset defaultCharset) { return getUncompressedContent(contentType, text, bodySize, contentSize, contentEncodingHeaderValue, harContentEncoding, comment, defaultCharset); } }
Hars { public static TypedContent translateResponseContent( String contentType, @Nullable String text, @Nullable Long bodySize, @Nullable Long contentSize, @Nullable String contentEncodingHeaderValue, @Nullable String harContentEncoding, @SuppressWarnings("unused") @Nullable String comment, Charset defaultCharset) { return getUncompressedContent(contentType, text, bodySize, contentSize, contentEncodingHeaderValue, harContentEncoding, comment, defaultCharset); }  }
Hars { public static TypedContent translateResponseContent( String contentType, @Nullable String text, @Nullable Long bodySize, @Nullable Long contentSize, @Nullable String contentEncodingHeaderValue, @Nullable String harContentEncoding, @SuppressWarnings("unused") @Nullable String comment, Charset defaultCharset) { return getUncompressedContent(contentType, text, bodySize, contentSize, contentEncodingHeaderValue, harContentEncoding, comment, defaultCharset); }  static boolean isBase64Encoded(String contentType, String text, @Nullable String harContentEncoding, @Nullable Long bodySize); @Nullable static ByteSource getRequestPostData(@Nullable List<NameValuePair> params, String contentType, String postDataText, @Nullable Long requestBodySize, @Nullable String postDataComment, Charset defaultCharset); static TypedContent translateResponseContent(              String contentType,
                                                                      @Nullable String text,
                                                                      @Nullable Long bodySize,
                                                                      @Nullable Long contentSize,
                                                                      @Nullable String contentEncodingHeaderValue,
                                                                      @Nullable String harContentEncoding,
                                                                      @SuppressWarnings("unused") @Nullable String comment,
                                                                      Charset defaultCharset); static HarHeader newHarHeader(String name, String value); }
Hars { public static TypedContent translateResponseContent( String contentType, @Nullable String text, @Nullable Long bodySize, @Nullable Long contentSize, @Nullable String contentEncodingHeaderValue, @Nullable String harContentEncoding, @SuppressWarnings("unused") @Nullable String comment, Charset defaultCharset) { return getUncompressedContent(contentType, text, bodySize, contentSize, contentEncodingHeaderValue, harContentEncoding, comment, defaultCharset); }  static boolean isBase64Encoded(String contentType, String text, @Nullable String harContentEncoding, @Nullable Long bodySize); @Nullable static ByteSource getRequestPostData(@Nullable List<NameValuePair> params, String contentType, String postDataText, @Nullable Long requestBodySize, @Nullable String postDataComment, Charset defaultCharset); static TypedContent translateResponseContent(              String contentType,
                                                                      @Nullable String text,
                                                                      @Nullable Long bodySize,
                                                                      @Nullable Long contentSize,
                                                                      @Nullable String contentEncodingHeaderValue,
                                                                      @Nullable String harContentEncoding,
                                                                      @SuppressWarnings("unused") @Nullable String comment,
                                                                      Charset defaultCharset); static HarHeader newHarHeader(String name, String value);  }