Skip to content

Commit f1632ec

Browse files
tomdalykdavisk6
authored andcommitted
Fix Response.InputStreamBody missing toString implementation (#1022)
Fixes #981
1 parent 55e4197 commit f1632ec

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

core/src/main/java/feign/Response.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import static feign.Util.checkNotNull;
1818
import static feign.Util.checkState;
1919
import static feign.Util.decodeOrDefault;
20+
import static feign.Util.toByteArray;
2021
import static feign.Util.valuesOrEmpty;
2122

2223
import java.io.ByteArrayInputStream;
@@ -273,6 +274,15 @@ public Reader asReader(Charset charset) throws IOException {
273274
public void close() throws IOException {
274275
inputStream.close();
275276
}
277+
278+
@Override
279+
public String toString() {
280+
try {
281+
return new String(toByteArray(inputStream), UTF_8);
282+
} catch (Exception e) {
283+
return super.toString();
284+
}
285+
}
276286
}
277287

278288
private static final class ByteArrayBody implements Response.Body {

0 commit comments

Comments
 (0)