Removed unused ChunkedInput.hasNextChunk()
This commit is contained in:
parent
98b2b6d8dc
commit
0382538548
@ -867,11 +867,6 @@ public class HttpPostRequestEncoder implements ChunkedInput {
|
|||||||
//NO since the user can want to reuse (broadcast for instance) cleanFiles();
|
//NO since the user can want to reuse (broadcast for instance) cleanFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasNextChunk() throws Exception {
|
|
||||||
return !isLastChunkSent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the next available HttpChunk. The caller is responsible to test if this chunk is the
|
* Returns the next available HttpChunk. The caller is responsible to test if this chunk is the
|
||||||
* last one (isLast()), in order to stop calling this method.
|
* last one (isLast()), in order to stop calling this method.
|
||||||
@ -949,10 +944,10 @@ public class HttpPostRequestEncoder implements ChunkedInput {
|
|||||||
return new DefaultHttpChunk(buffer);
|
return new DefaultHttpChunk(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEndOfInput() throws Exception {
|
public boolean isEndOfInput() throws Exception {
|
||||||
return isLastChunkSent;
|
return isLastChunkSent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception when an error occurs while encoding
|
* Exception when an error occurs while encoding
|
||||||
|
@ -131,14 +131,9 @@ public class ChunkedFile implements ChunkedInput {
|
|||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasNextChunk() throws Exception {
|
|
||||||
return offset < endOffset && file.getChannel().isOpen();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEndOfInput() throws Exception {
|
public boolean isEndOfInput() throws Exception {
|
||||||
return !hasNextChunk();
|
return !(offset < endOffset && file.getChannel().isOpen());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,14 +28,6 @@ import org.jboss.netty.buffer.ChannelBuffer;
|
|||||||
*/
|
*/
|
||||||
public interface ChunkedInput {
|
public interface ChunkedInput {
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns {@code true} if and only if there is any data left in the
|
|
||||||
* stream. Please note that {@code false} does not necessarily mean that
|
|
||||||
* the stream has reached at its end. In a slow stream, the next chunk
|
|
||||||
* might be unavailable just momentarily.
|
|
||||||
*/
|
|
||||||
boolean hasNextChunk() throws Exception;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches a chunked data from the stream. The returned chunk is usually
|
* Fetches a chunked data from the stream. The returned chunk is usually
|
||||||
* a {@link ChannelBuffer}, but you could extend an existing implementation
|
* a {@link ChannelBuffer}, but you could extend an existing implementation
|
||||||
|
@ -137,14 +137,9 @@ public class ChunkedNioFile implements ChunkedInput {
|
|||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasNextChunk() throws Exception {
|
|
||||||
return offset < endOffset && in.isOpen();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEndOfInput() throws Exception {
|
public boolean isEndOfInput() throws Exception {
|
||||||
return !hasNextChunk();
|
return !(offset < endOffset && in.isOpen());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -79,27 +79,22 @@ public class ChunkedNioStream implements ChunkedInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNextChunk() throws Exception {
|
public boolean isEndOfInput() throws Exception {
|
||||||
if (byteBuffer.position() > 0) {
|
if (byteBuffer.position() > 0) {
|
||||||
// A previous read was not over, so there is a next chunk in the buffer at least
|
// A previous read was not over, so there is a next chunk in the buffer at least
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
if (in.isOpen()) {
|
if (in.isOpen()) {
|
||||||
// Try to read a new part, and keep this part (no rewind)
|
// Try to read a new part, and keep this part (no rewind)
|
||||||
int b = in.read(byteBuffer);
|
int b = in.read(byteBuffer);
|
||||||
if (b < 0) {
|
if (b < 0) {
|
||||||
return false;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
offset += b;
|
offset += b;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEndOfInput() throws Exception {
|
|
||||||
return !hasNextChunk();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -109,7 +104,7 @@ public class ChunkedNioStream implements ChunkedInput {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object nextChunk() throws Exception {
|
public Object nextChunk() throws Exception {
|
||||||
if (!hasNextChunk()) {
|
if (isEndOfInput()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// buffer cannot be not be empty from there
|
// buffer cannot be not be empty from there
|
||||||
|
@ -75,21 +75,16 @@ public class ChunkedStream implements ChunkedInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNextChunk() throws Exception {
|
public boolean isEndOfInput() throws Exception {
|
||||||
int b = in.read();
|
int b = in.read();
|
||||||
if (b < 0) {
|
if (b < 0) {
|
||||||
return false;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
in.unread(b);
|
in.unread(b);
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEndOfInput() throws Exception {
|
|
||||||
return !hasNextChunk();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws Exception {
|
public void close() throws Exception {
|
||||||
in.close();
|
in.close();
|
||||||
@ -97,7 +92,7 @@ public class ChunkedStream implements ChunkedInput {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object nextChunk() throws Exception {
|
public Object nextChunk() throws Exception {
|
||||||
if (!hasNextChunk()) {
|
if (isEndOfInput()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user