title: Spring Cloud Open Feign: linebreaks "\n" stripped from gzip response body
body: <p>Linebreaks (&quot;\n&quot; or &quot;\r&quot;) are been stripped out from <strong>gzip</strong> response body, when using response compression configuration (as below) in Spring Cloud Open Feign. There are no errors raised. Linebreaks are just been replace by an empty string &quot;&quot;. The response has the correct &quot;content-encoding: gzip&quot; header, and a well formed gzipped body content.</p>
  <p>Does someone has a clue? It seems a issue for me as I opened here <a href="https://github.com/spring-cloud/spring-cloud-openfeign/issues/400" rel="nofollow noreferrer">spring-cloud-openfeign/issue400</a></p>
  <pre><code>feign.compression.response.enabled: true
  feign.compression.response.useGzipDecoder: true
  
  # Same behaviour using Apache Http as client
  feign.httpclient.enabled: true
  </code></pre>
  <p>SpringCloudFeignClient.java</p>
  <pre><code>package springcloudfeigngzip;
  import org.springframework.cloud.openfeign.FeignClient;
  import org.springframework.web.bind.annotation.GetMapping;
  
  @FeignClient(name = &quot;SpringCloudFeignClient&quot;, url = &quot;http://localhost:8082&quot;)
  public interface SpringCloudFeignClient {
      @GetMapping(value = &quot;/gzip&quot;)
      String getGzippedString();     
  }
  </code></pre>
  <p>ApplicationTest.java:</p>
  <pre><code>package springcloudfeigngzip;
  
  import org.junit.jupiter.api.Test;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.boot.test.context.SpringBootTest;
  import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
  import static com.github.tomakehurst.wiremock.client.WireMock.*;
  import static org.junit.jupiter.api.Assertions.assertEquals;
  
  @SpringBootTest
  @AutoConfigureWireMock(port = 8082)
  class ApplicationTest {
      @Autowired
      private SpringCloudFeignClient springCloudFeignClient;
  
      @Test
      void success_GzipOneLine() {
          stubFor(get(urlEqualTo(&quot;/gzip&quot;)).withHeader(&quot;Accept-Encoding&quot;, containing(&quot;gzip&quot;))
                  .willReturn(aResponse().withStatus(200).withBody(&quot;lineone&quot;)));
      
          String response = springCloudFeignClient.getGzippedString();
          assertEquals(&quot;lineone&quot;, response); //success
      }
  
      @Test
      void fail_GzipLineBreak() {
          stubFor(get(urlEqualTo(&quot;/gzip&quot;)).withHeader(&quot;Accept-Encoding&quot;, containing(&quot;gzip&quot;))
                  .willReturn(aResponse().withStatus(200).withBody(&quot;lineone\nlinetwo&quot;)));
      
          String response = springCloudFeignClient.getGzippedString();
          assertEquals(&quot;lineone\nlinetwo&quot;, response); //fail!
      }
  }
  </code></pre>
  <p>bootstrap.yml:</p>
  <pre><code>feign:
    compression:
      response:
        enabled: true
        useGzipDecoder: true
  </code></pre>
  <p>Versions:</p>
  <pre><code>org.springframework.boot: 2.3.3.RELEASE
  org.springframework.cloud: Hoxton.SR8
  </code></pre>
  <p>Full project here:
  <a href="https://github.com/spring-cloud/spring-cloud-openfeign/files/5147346/spring-cloud-feign-gzip.zip" rel="nofollow noreferrer">https://github.com/spring-cloud/spring-cloud-openfeign/files/5147346/spring-cloud-feign-gzip.zip</a></p>