Skip to content

Commit 0a0ff3f

Browse files
tomdalykdavisk6
authored andcommitted
Fix Response.InputStreamBody missing toString implementation (#1022)
Fixes #981
1 parent 3477a04 commit 0a0ff3f

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
@@ -32,6 +32,7 @@
3232
import static feign.Util.checkState;
3333
import static feign.Util.decodeOrDefault;
3434
import static feign.Util.valuesOrEmpty;
35+
import static feign.Util.toByteArray;
3536

3637
/**
3738
* An immutable response to an http invocation which only returns string content.
@@ -277,6 +278,15 @@ public Reader asReader(Charset charset) throws IOException {
277278
public void close() throws IOException {
278279
inputStream.close();
279280
}
281+
282+
@Override
283+
public String toString() {
284+
try {
285+
return new String(toByteArray(inputStream), UTF_8);
286+
} catch (Exception e) {
287+
return super.toString();
288+
}
289+
}
280290
}
281291

282292
private static final class ByteArrayBody implements Response.Body {

0 commit comments

Comments
 (0)