Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solved issue 1303 #1329

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions src/main/java/org/takes/rq/ChunkedInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,27 @@ public int read(final byte[] buf, final int off, final int len)
throws IOException {
if (!this.eof && this.pos >= this.size) {
this.nextChunk();
}
final int result;
}
if (this.eof) {
result = -1;
return -1;
} else {
final int shift = Math.min(len, this.size - this.pos);
final int count = this.origin.read(buf, off, shift);
this.pos += count;
if (shift == len) {
result = len;
} else {
result = shift + this.read(buf, off + shift, len - shift);
if (count == -1) {
this.eof = true;
return (shift == 0) ? -1 : shift;
} else if (count > 0) {
this.pos += count;
}
if (shift < len) {
int additional = this.read(buf, off + count, len - count);
if (additional < 0) {
this.eof = true;
return count;
}
return count + additional;
}
return result;
return count;
}

@Override
Expand Down