From b87c013947d59cca92e853a02f2d2d6ae41ef586 Mon Sep 17 00:00:00 2001 From: Jonathan Hedley Date: Sun, 12 May 2019 15:34:21 -0700 Subject: [PATCH] Test binary to byte fetch OK --- src/test/java/org/jsoup/integration/ConnectTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test/java/org/jsoup/integration/ConnectTest.java b/src/test/java/org/jsoup/integration/ConnectTest.java index 386ff43b38..f2bb871986 100644 --- a/src/test/java/org/jsoup/integration/ConnectTest.java +++ b/src/test/java/org/jsoup/integration/ConnectTest.java @@ -539,4 +539,16 @@ public void testBinaryContentTypeThrowsException() { } assertTrue(threw); } + + @Test + public void canFetchBinaryAsBytes() throws IOException { + Connection.Response res = Jsoup.connect(FileServlet.Url) + .data(FileServlet.LocationParam, "/htmltests/thumb.jpg") + .data(FileServlet.ContentTypeParam, "image/jpeg") + .ignoreContentType(true) + .execute(); + + byte[] bytes = res.bodyAsBytes(); + assertEquals(1052, bytes.length); + } }