@Override public int fillBuffer(final ReadableByteChannel channel) throws IOException { final int bytesRead = this.sessionBuffer.fill(channel); if (bytesRead == -1) { this.endOfStream = true; } return bytesRead; }
@Override public int read(final ByteBuffer dst) throws IOException { Args.notNull(dst, "Byte buffer"); if (this.completed) { return -1; } final int bytesRead; if (this.buffer.hasData()) { bytesRead = this.buffer.read(dst); } else { bytesRead = readFromChannel(dst); } if (bytesRead == -1) { this.completed = true; } return bytesRead; }
this.lineBuf.clear(); final boolean lineComplete = this.sessionBuffer.readLine(this.lineBuf, this.endOfStream); final int maxLineLen = this.constraints.getMaxLineLength(); if (maxLineLen > 0 && (this.lineBuf.length() > maxLineLen || (!lineComplete && this.sessionBuffer.length() > maxLineLen))) { throw new MessageConstraintException("Maximum line length limit exceeded"); if (this.endOfStream && !this.sessionBuffer.hasData()) { this.state = COMPLETED;
while (this.state != COMPLETED) { if (!this.buffer.hasData() || this.chunkSize == -1) { final int bytesRead = fillBufferFromChannel(); if (bytesRead == -1) { final int len = this.buffer.read(dst, maxLen); if (len > 0) { this.pos += len; totalRead += len; } else { if (!this.buffer.hasData() && this.endOfStream) { this.state = COMPLETED; this.completed = true; this.lineBuf.clear(); if (!this.buffer.readLine(this.lineBuf, this.endOfStream)) {
if (this.buffer.readLine(this.lineBuf, this.endOfStream)) { if (!this.lineBuf.isEmpty()) { throw new MalformedChunkCodingException("CRLF expected at end of chunk"); if (this.buffer.length() > 2 || this.endOfStream) { throw new MalformedChunkCodingException("CRLF expected at end of chunk"); final boolean lineComplete = this.buffer.readLine(this.lineBuf, this.endOfStream); final int maxLineLen = this.constraints.getMaxLineLength(); if (maxLineLen > 0 && (this.lineBuf.length() > maxLineLen || (!lineComplete && this.buffer.length() > maxLineLen))) { throw new MessageConstraintException("Maximum line length limit exceeded");
this.lineBuf.clear(); final boolean lineComplete = this.sessionBuffer.readLine(this.lineBuf, this.endOfStream); final int maxLineLen = this.constraints.getMaxLineLength(); if (maxLineLen > 0 && (this.lineBuf.length() > maxLineLen || (!lineComplete && this.sessionBuffer.length() > maxLineLen))) { throw new MessageConstraintException("Maximum line length limit exceeded"); if (this.endOfStream && !this.sessionBuffer.hasData()) { this.state = COMPLETED;
while (this.state != COMPLETED) { if (!this.buffer.hasData() || this.chunkSize == -1) { final int bytesRead = fillBufferFromChannel(); if (bytesRead == -1) { final int len = this.buffer.read(dst, maxLen); if (len > 0) { this.pos += len; totalRead += len; } else { if (!this.buffer.hasData() && this.endOfStream) { this.state = COMPLETED; this.completed = true; this.lineBuf.clear(); if (!this.buffer.readLine(this.lineBuf, this.endOfStream)) {
if (this.buffer.readLine(this.lineBuf, this.endOfStream)) { if (!this.lineBuf.isEmpty()) { throw new MalformedChunkCodingException("CRLF expected at end of chunk"); if (this.buffer.length() > 2 || this.endOfStream) { throw new MalformedChunkCodingException("CRLF expected at end of chunk"); final boolean lineComplete = this.buffer.readLine(this.lineBuf, this.endOfStream); final int maxLineLen = this.constraints.getMaxLineLength(); if (maxLineLen > 0 && (this.lineBuf.length() > maxLineLen || (!lineComplete && this.buffer.length() > maxLineLen))) { throw new MessageConstraintException("Maximum line length limit exceeded");
@Override public int read(final ByteBuffer dst) throws IOException { Args.notNull(dst, "Byte buffer"); if (this.completed) { return -1; } final int bytesRead; if (this.buffer.hasData()) { bytesRead = this.buffer.read(dst); } else { bytesRead = readFromChannel(dst); } if (bytesRead == -1) { this.completed = true; } return bytesRead; }
@Override public int fillBuffer(final ReadableByteChannel channel) throws IOException { final int bytesRead = this.sessionBuffer.fill(channel); if (bytesRead == -1) { this.endOfStream = true; } return bytesRead; }
/** * Reads from the channel to the session buffer. * @return number of bytes transferred. * * @since 4.3 */ protected int fillBufferFromChannel() throws IOException { final int bytesRead = this.buffer.fill(this.channel); if (bytesRead > 0) { this.metrics.incrementBytesTransferred(bytesRead); } return bytesRead; }
/** * Reads from the channel to the session buffer. * @return number of bytes transferred. * * @since 4.3 */ protected int fillBufferFromChannel() throws IOException { final int bytesRead = this.buffer.fill(this.channel); if (bytesRead > 0) { this.metrics.incrementBytesTransferred(bytesRead); } return bytesRead; }