Commit 00ea7973 authored by Kanagat Nugusbayev's avatar Kanagat Nugusbayev
Browse files

fixed response handle

1 merge request!12180Feature handle chunked response v530
Pipeline #626 failed with stages
in 0 seconds
Showing with 12 additions and 10 deletions
+12 -10
......@@ -972,16 +972,18 @@ public class ApiClient {
String respBody = null;
try {
if (response.body() != null)
if ("chunked".equals(response.header("Transfer-Encoding"))) {
BufferedSource source = response.body().source();
Buffer buffer = new Buffer();
while (!source.exhausted()) {
Long readBytes = source.read(buffer, Long.MAX_VALUE);
respBody = buffer.readString(Charset.defaultCharset());
}
} else {
respBody = response.body().string();
}
if ("chunked".equals(response.header("Transfer-Encoding"))) {
BufferedSource source = response.body().source();
Buffer buffer = new Buffer();
StringBuilder result = new StringBuilder();
while (!source.exhausted()) {
Long readBytes = source.read(buffer, Long.MAX_VALUE);
result.append(buffer.readString(Charset.defaultCharset()));
}
respBody = result.toString();
} else {
respBody = response.body().string();
}
else
respBody = null;
} catch (IOException e) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment