don't ask the bandwidth limiter to authorize reading an EOF ;)

(this fixes the longstanding "-318 bytes read" bug)
This commit is contained in:
jrandom
2004-08-26 17:59:47 +00:00
committed by zzz
parent 2eb8b84bbd
commit c73f3385c0

View File

@ -62,6 +62,8 @@ public class BandwidthLimitedInputStream extends FilterInputStream {
public int read(byte dest[], int off, int len) throws IOException { public int read(byte dest[], int off, int len) throws IOException {
int read = in.read(dest, off, len); int read = in.read(dest, off, len);
if (read == -1) return -1;
if (_pullFromOutbound) if (_pullFromOutbound)
_currentRequest = _context.bandwidthLimiter().requestOutbound(read, _peerSource); _currentRequest = _context.bandwidthLimiter().requestOutbound(read, _peerSource);
else else
@ -84,6 +86,7 @@ public class BandwidthLimitedInputStream extends FilterInputStream {
} }
public long skip(long numBytes) throws IOException { public long skip(long numBytes) throws IOException {
long skip = in.skip(numBytes); long skip = in.skip(numBytes);
if (_pullFromOutbound) if (_pullFromOutbound)
_currentRequest = _context.bandwidthLimiter().requestOutbound((int)skip, _peerSource); _currentRequest = _context.bandwidthLimiter().requestOutbound((int)skip, _peerSource);
else else