@@ -419,6 +419,25 @@ public void canSupportGzipOnError() throws Exception {
419419
420420 }
421421
422+ @ Test
423+ public void canSupportGzipOnErrorWithoutBody () throws Exception {
424+ server .enqueue (new MockResponse ().setResponseCode (400 )
425+ .addHeader ("Content-Encoding" , "gzip" ));
426+
427+ TestInterface api =
428+ newBuilder ().target (TestInterface .class , "http://localhost:" + server .getPort ());
429+
430+ try {
431+ api .get ();
432+ fail ("Expect FeignException" );
433+ } catch (FeignException e ) {
434+ /* verify that the response is unzipped */
435+ assertThat (e .responseBody ()).isNotEmpty ()
436+ .map (body -> new String (body .array (), StandardCharsets .UTF_8 ))
437+ .get ().isEqualTo ("" );
438+ }
439+ }
440+
422441 @ Test
423442 public void canSupportDeflate () throws Exception {
424443 /* enqueue a zipped response */
@@ -456,6 +475,25 @@ public void canSupportDeflateOnError() throws Exception {
456475 }
457476 }
458477
478+ @ Test
479+ public void canSupportDeflateOnErrorWithoutBody () throws Exception {
480+ server .enqueue (new MockResponse ().setResponseCode (400 )
481+ .addHeader ("Content-Encoding" , "deflate" ));
482+
483+ TestInterface api =
484+ newBuilder ().target (TestInterface .class , "http://localhost:" + server .getPort ());
485+
486+ try {
487+ api .get ();
488+ fail ("Expect FeignException" );
489+ } catch (FeignException e ) {
490+ /* verify that the response is unzipped */
491+ assertThat (e .responseBody ()).isNotEmpty ()
492+ .map (body -> new String (body .array (), StandardCharsets .UTF_8 ))
493+ .get ().isEqualTo ("" );
494+ }
495+ }
496+
459497 @ Test
460498 public void canExceptCaseInsensitiveHeader () throws Exception {
461499 /* enqueue a zipped response */
0 commit comments