//continue
size -= buffer.readableBytes() + 1;
}
if (currentBuffer.readableBytes() >= HttpPostBodyUtil.chunkSize) {
buffer = fillChannelBuffer();
return new DefaultHttpChunk(buffer);
}
}
try {
buffer = ((HttpData) currentData).getChunk(size);
} catch (IOException e) {
throw new ErrorDataEncoderException(e);
}
ChannelBuffer delimiter = null;
if (buffer.readableBytes() < size) {
// delimiter
isKey = true;
delimiter = iterator.hasNext() ?
ChannelBuffers.wrappedBuffer("&".getBytes()) :
null;
}
if (buffer.capacity() == 0) {
// end for current InterfaceHttpData, need potentially more data
currentData = null;
if (currentBuffer == null) {
currentBuffer = delimiter;
} else {
if (delimiter != null) {
currentBuffer = ChannelBuffers.wrappedBuffer(currentBuffer,
delimiter);
}
}
if (currentBuffer.readableBytes() >= HttpPostBodyUtil.chunkSize) {
buffer = fillChannelBuffer();
return new DefaultHttpChunk(buffer);
}
return null;
}
if (currentBuffer == null) {
if (delimiter != null) {
currentBuffer = ChannelBuffers.wrappedBuffer(buffer,
delimiter);
} else {
currentBuffer = buffer;
}
} else {
if (delimiter != null) {
currentBuffer = ChannelBuffers.wrappedBuffer(currentBuffer,
buffer, delimiter);
} else {
currentBuffer = ChannelBuffers.wrappedBuffer(currentBuffer,
buffer);
}
}
if (currentBuffer.readableBytes() < HttpPostBodyUtil.chunkSize) {
// end for current InterfaceHttpData, need more data
currentData = null;
isKey = true;
return null;
}
buffer = fillChannelBuffer();
// size = 0
return new DefaultHttpChunk(buffer);
}