Skip to content

Commit

Permalink
Added Deflate Support and removed implict response body reading
Browse files Browse the repository at this point in the history
Fixes: #1208

Forgot to add Defate support and removed the implicit parsing of the
body during toString.  This was also brought up in #1208 and it came up
during testing of this change.  Users should be using our `asReader`
and other methods to access the response body.
  • Loading branch information
kdavisk6 committed Dec 29, 2020
1 parent 787c890 commit d7fe851
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 48 deletions.
12 changes: 0 additions & 12 deletions core/src/test/java/feign/AsyncFeignTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,6 @@ public void postTemplateParamsResolve() throws Exception {
"{\"customer_name\": \"netflix\", \"user_name\": \"denominator\", \"password\": \"password\"}");
}

@Test
public void responseCoercesToStringBody() throws Throwable {
server.enqueue(new MockResponse().setBody("foo"));

TestInterfaceAsync api =
new TestInterfaceAsyncBuilder().target("http://localhost:" + server.getPort());

Response response = unwrap(api.response());
assertTrue(response.body().isRepeatable());
assertEquals("foo", response.body().toString());
}

@Test
public void postFormParams() throws Exception {
server.enqueue(new MockResponse().setBody("foo"));
Expand Down
11 changes: 0 additions & 11 deletions core/src/test/java/feign/FeignTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,6 @@ public void postTemplateParamsResolve() throws Exception {
"{\"customer_name\": \"netflix\", \"user_name\": \"denominator\", \"password\": \"password\"}");
}

@Test
public void responseCoercesToStringBody() {
server.enqueue(new MockResponse().setBody("foo"));

TestInterface api = new TestInterfaceBuilder().target("http://localhost:" + server.getPort());

Response response = api.response();
assertTrue(response.body().isRepeatable());
assertEquals("foo", response.body().toString());
}

@Test
public void postFormParams() throws Exception {
server.enqueue(new MockResponse().setBody("foo"));
Expand Down
11 changes: 0 additions & 11 deletions core/src/test/java/feign/FeignUnderAsyncTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,6 @@ public void postTemplateParamsResolve() throws Exception {
"{\"customer_name\": \"netflix\", \"user_name\": \"denominator\", \"password\": \"password\"}");
}

@Test
public void responseCoercesToStringBody() {
server.enqueue(new MockResponse().setBody("foo"));

TestInterface api = new TestInterfaceBuilder().target("http://localhost:" + server.getPort());

Response response = api.response();
assertTrue(response.body().isRepeatable());
assertEquals("foo", response.body().toString());
}

@Test
public void postFormParams() throws Exception {
server.enqueue(new MockResponse().setBody("foo"));
Expand Down
3 changes: 2 additions & 1 deletion core/src/test/java/feign/ResponseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package feign;

import feign.Request.HttpMethod;
import java.nio.charset.StandardCharsets;
import org.assertj.core.util.Lists;
import org.junit.Test;
import java.util.Arrays;
Expand All @@ -38,7 +39,7 @@ public void reasonPhraseIsOptional() {
.build();

assertThat(response.reason()).isNull();
assertThat(response.toString()).isEqualTo("HTTP/1.1 200\n\n");
assertThat(response.toString()).startsWith("HTTP/1.1 200");
}

@Test
Expand Down
12 changes: 0 additions & 12 deletions hc5/src/test/java/feign/hc5/AsyncApacheHttp5ClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,6 @@ public void postTemplateParamsResolve() throws Exception {
"{\"customer_name\": \"netflix\", \"user_name\": \"denominator\", \"password\": \"password\"}");
}

@Test
public void responseCoercesToStringBody() throws Throwable {
server.enqueue(new MockResponse().setBody("foo"));

final TestInterfaceAsync api =
new TestInterfaceAsyncBuilder().target("http://localhost:" + server.getPort());

final Response response = unwrap(api.response());
assertTrue(response.body().isRepeatable());
assertEquals("foo", response.body().toString());
}

@Test
public void postFormParams() throws Exception {
server.enqueue(new MockResponse().setBody("foo"));
Expand Down
4 changes: 3 additions & 1 deletion okhttp/src/test/java/feign/okhttp/OkHttpClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import feign.assertj.MockWebServerAssertions;
import feign.client.AbstractClientTest;
import feign.Feign;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.concurrent.TimeUnit;
import okhttp3.mockwebserver.MockResponse;
Expand Down Expand Up @@ -97,7 +98,8 @@ public void testFollowRedirect() throws Exception {
Response response = api.get();
// Response length should not be null
assertEquals(200, response.status());
assertEquals(expectedBody, response.body().toString());
String payload = Util.toString(response.body().asReader(StandardCharsets.UTF_8));
assertEquals(expectedBody, payload);

}

Expand Down

0 comments on commit d7fe851

Please sign in to comment.