Skip to content

Commit d7fe851

Browse files
committed
Added Deflate Support and removed implict response body reading
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.
1 parent 787c890 commit d7fe851

File tree

6 files changed

+5
-48
lines changed

6 files changed

+5
-48
lines changed

core/src/test/java/feign/AsyncFeignTest.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,6 @@ public void postTemplateParamsResolve() throws Exception {
9191
"{\"customer_name\": \"netflix\", \"user_name\": \"denominator\", \"password\": \"password\"}");
9292
}
9393

94-
@Test
95-
public void responseCoercesToStringBody() throws Throwable {
96-
server.enqueue(new MockResponse().setBody("foo"));
97-
98-
TestInterfaceAsync api =
99-
new TestInterfaceAsyncBuilder().target("http://localhost:" + server.getPort());
100-
101-
Response response = unwrap(api.response());
102-
assertTrue(response.body().isRepeatable());
103-
assertEquals("foo", response.body().toString());
104-
}
105-
10694
@Test
10795
public void postFormParams() throws Exception {
10896
server.enqueue(new MockResponse().setBody("foo"));

core/src/test/java/feign/FeignTest.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,6 @@ public void postTemplateParamsResolve() throws Exception {
9292
"{\"customer_name\": \"netflix\", \"user_name\": \"denominator\", \"password\": \"password\"}");
9393
}
9494

95-
@Test
96-
public void responseCoercesToStringBody() {
97-
server.enqueue(new MockResponse().setBody("foo"));
98-
99-
TestInterface api = new TestInterfaceBuilder().target("http://localhost:" + server.getPort());
100-
101-
Response response = api.response();
102-
assertTrue(response.body().isRepeatable());
103-
assertEquals("foo", response.body().toString());
104-
}
105-
10695
@Test
10796
public void postFormParams() throws Exception {
10897
server.enqueue(new MockResponse().setBody("foo"));

core/src/test/java/feign/FeignUnderAsyncTest.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,6 @@ public void postTemplateParamsResolve() throws Exception {
8989
"{\"customer_name\": \"netflix\", \"user_name\": \"denominator\", \"password\": \"password\"}");
9090
}
9191

92-
@Test
93-
public void responseCoercesToStringBody() {
94-
server.enqueue(new MockResponse().setBody("foo"));
95-
96-
TestInterface api = new TestInterfaceBuilder().target("http://localhost:" + server.getPort());
97-
98-
Response response = api.response();
99-
assertTrue(response.body().isRepeatable());
100-
assertEquals("foo", response.body().toString());
101-
}
102-
10392
@Test
10493
public void postFormParams() throws Exception {
10594
server.enqueue(new MockResponse().setBody("foo"));

core/src/test/java/feign/ResponseTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
package feign;
1515

1616
import feign.Request.HttpMethod;
17+
import java.nio.charset.StandardCharsets;
1718
import org.assertj.core.util.Lists;
1819
import org.junit.Test;
1920
import java.util.Arrays;
@@ -38,7 +39,7 @@ public void reasonPhraseIsOptional() {
3839
.build();
3940

4041
assertThat(response.reason()).isNull();
41-
assertThat(response.toString()).isEqualTo("HTTP/1.1 200\n\n");
42+
assertThat(response.toString()).startsWith("HTTP/1.1 200");
4243
}
4344

4445
@Test

hc5/src/test/java/feign/hc5/AsyncApacheHttp5ClientTest.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,6 @@ public void postTemplateParamsResolve() throws Exception {
7676
"{\"customer_name\": \"netflix\", \"user_name\": \"denominator\", \"password\": \"password\"}");
7777
}
7878

79-
@Test
80-
public void responseCoercesToStringBody() throws Throwable {
81-
server.enqueue(new MockResponse().setBody("foo"));
82-
83-
final TestInterfaceAsync api =
84-
new TestInterfaceAsyncBuilder().target("http://localhost:" + server.getPort());
85-
86-
final Response response = unwrap(api.response());
87-
assertTrue(response.body().isRepeatable());
88-
assertEquals("foo", response.body().toString());
89-
}
90-
9179
@Test
9280
public void postFormParams() throws Exception {
9381
server.enqueue(new MockResponse().setBody("foo"));

okhttp/src/test/java/feign/okhttp/OkHttpClientTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import feign.assertj.MockWebServerAssertions;
2323
import feign.client.AbstractClientTest;
2424
import feign.Feign;
25+
import java.nio.charset.StandardCharsets;
2526
import java.util.Collections;
2627
import java.util.concurrent.TimeUnit;
2728
import okhttp3.mockwebserver.MockResponse;
@@ -97,7 +98,8 @@ public void testFollowRedirect() throws Exception {
9798
Response response = api.get();
9899
// Response length should not be null
99100
assertEquals(200, response.status());
100-
assertEquals(expectedBody, response.body().toString());
101+
String payload = Util.toString(response.body().asReader(StandardCharsets.UTF_8));
102+
assertEquals(expectedBody, payload);
101103

102104
}
103105

0 commit comments

Comments
 (0)