Skip to content

Commit

Permalink
Fix Response.InputStreamBody missing toString implementation (#1022)
Browse files Browse the repository at this point in the history
Fixes #981
  • Loading branch information
tomdaly authored and kdavisk6 committed Aug 2, 2019
1 parent 3477a04 commit 0a0ff3f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/src/main/java/feign/Response.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import static feign.Util.checkState;
import static feign.Util.decodeOrDefault;
import static feign.Util.valuesOrEmpty;
import static feign.Util.toByteArray;

/**
* An immutable response to an http invocation which only returns string content.
Expand Down Expand Up @@ -277,6 +278,15 @@ public Reader asReader(Charset charset) throws IOException {
public void close() throws IOException {
inputStream.close();
}

@Override
public String toString() {
try {
return new String(toByteArray(inputStream), UTF_8);
} catch (Exception e) {
return super.toString();
}
}
}

private static final class ByteArrayBody implements Response.Body {
Expand Down

0 comments on commit 0a0ff3f

Please sign in to comment.