Commit 654d914b by olly Committed by Oliver Woodman

Fix DefaultHttpDataSource read when requested length is 0

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=134063990
parent 669cf680
...@@ -547,11 +547,8 @@ public class DefaultHttpDataSource implements HttpDataSource { ...@@ -547,11 +547,8 @@ public class DefaultHttpDataSource implements HttpDataSource {
* @throws IOException If an error occurs reading from the source. * @throws IOException If an error occurs reading from the source.
*/ */
private int readInternal(byte[] buffer, int offset, int readLength) throws IOException { private int readInternal(byte[] buffer, int offset, int readLength) throws IOException {
readLength = bytesToRead == C.LENGTH_UNSET ? readLength
: (int) Math.min(readLength, bytesToRead - bytesRead);
if (readLength == 0) { if (readLength == 0) {
// We've read all of the requested data. return 0;
return C.RESULT_END_OF_INPUT;
} }
int read = inputStream.read(buffer, offset, readLength); int read = inputStream.read(buffer, offset, readLength);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment