public int doWrite(ByteChunk chunk) { final int start = chunk.getStart(); final int end = chunk.getEnd(); final int length = end - start; if (length == 0) { return 0; } // NB: We make a copy because Tomcat reuses the underlying byte array of 'chunk'. final byte[] content = Arrays.copyOfRange(chunk.getBuffer(), start, end); data.add(HttpData.of(content)); bytesWritten += length; return length; }
@Override public int doWrite(ByteChunk chunk, Response response) throws IOException { final int start = chunk.getStart(); final int end = chunk.getEnd(); final int length = end - start; if (length == 0) { return 0; } // NB: We make a copy because Tomcat reuses the underlying byte array of 'chunk'. final byte[] content = Arrays.copyOfRange(chunk.getBuffer(), start, end); data.add(HttpData.of(content)); bytesWritten += length; return length; }
@Override public boolean isFinished() { return input.getOffset() >= input.getEnd(); } }
@Override public boolean isFinished() { return input.getOffset() >= input.getEnd(); } }
@Override public int doRead(ApplicationBufferHandler handler) throws IOException { if(input.getOffset()>= input.getEnd()) return -1; ByteBuffer byteBuffer = handler.getByteBuffer(); byteBuffer.position(byteBuffer.limit()).limit(byteBuffer.capacity()); input.subtract(byteBuffer); return byteBuffer.remaining(); }
protected void urlEncode(CharChunk out, ByteChunk bb) throws IOException { byte[] bytes = bb.getBuffer(); for (int j = bb.getStart(); j < bb.getEnd(); j++) { out.append('%'); char ch = Character.forDigit((bytes[j] >> 4) & 0xF, 16); out.append(ch); ch = Character.forDigit(bytes[j] & 0xF, 16); out.append(ch); } }
public MessageBytesReader(MessageBytes mb) { ByteChunk bc = mb.getByteChunk(); bytes = bc.getBytes(); pos = bc.getOffset(); end = bc.getEnd(); }
protected void urlEncode(CharChunk out, ByteChunk bb) throws IOException { byte[] bytes = bb.getBuffer(); for (int j = bb.getStart(); j < bb.getEnd(); j++) { out.append('%'); char ch = Character.forDigit((bytes[j] >> 4) & 0xF, 16); out.append(ch); ch = Character.forDigit(bytes[j] & 0xF, 16); out.append(ch); } }
protected void urlEncode(CharChunk out, ByteChunk bb) throws IOException { byte[] bytes = bb.getBuffer(); for (int j = bb.getStart(); j < bb.getEnd(); j++) { out.append('%'); char ch = Character.forDigit((bytes[j] >> 4) & 0xF, 16); out.append(ch); ch = Character.forDigit(bytes[j] & 0xF, 16); out.append(ch); } }
protected void urlEncode(CharChunk out, ByteChunk bb) throws IOException { byte[] bytes = bb.getBuffer(); for (int j = bb.getStart(); j < bb.getEnd(); j++) { out.append('%'); char ch = Character.forDigit((bytes[j] >> 4) & 0xF, 16); out.append(ch); ch = Character.forDigit(bytes[j] & 0xF, 16); out.append(ch); } }
protected void urlEncode(CharChunk out, ByteChunk bb) throws IOException { byte[] bytes = bb.getBuffer(); for (int j = bb.getStart(); j < bb.getEnd(); j++) { out.append('%'); char ch = Character.forDigit((bytes[j] >> 4) & 0xF, 16); out.append(ch); ch = Character.forDigit(bytes[j] & 0xF, 16); out.append(ch); } }
/** * Read bytes. */ public int doRead(ByteChunk chunk, org.apache.coyote.Request request) throws IOException { int writeLength = 0; if (chunk.getLimit() > 0 && chunk.getLimit() < input.getLength()) { writeLength = chunk.getLimit(); } else { writeLength = input.getLength(); } if(input.getOffset()>= input.getEnd()) return -1; input.substract(chunk.getBuffer(), 0, writeLength); chunk.setOffset(0); chunk.setEnd(writeLength); return writeLength; }
/** * Read bytes. */ public int doRead(ByteChunk chunk, org.apache.coyote.Request request) throws IOException { int writeLength = 0; if (chunk.getLimit() > 0 && chunk.getLimit() < input.getLength()) { writeLength = chunk.getLimit(); } else { writeLength = input.getLength(); } if(input.getOffset()>= input.getEnd()) return -1; input.substract(chunk.getBuffer(), 0, writeLength); chunk.setOffset(0); chunk.setEnd(writeLength); return writeLength; }
/** * Read bytes. */ @Override public int doRead(ByteChunk chunk, org.apache.coyote.Request request) throws IOException { if(input.getOffset()>= input.getEnd()) return -1; int writeLength = 0; if (chunk.getLimit() > 0 && chunk.getLimit() < input.getLength()) { writeLength = chunk.getLimit(); } else { writeLength = input.getLength(); } input.substract(chunk.getBuffer(), 0, writeLength); chunk.setOffset(0); chunk.setEnd(writeLength); return writeLength; }
/** * Read bytes. */ public int doRead(ByteChunk chunk, org.apache.coyote.Request request) throws IOException { int writeLength = 0; if (chunk.getLimit() > 0 && chunk.getLimit() < input.getLength()) { writeLength = chunk.getLimit(); } else { writeLength = input.getLength(); } if(input.getOffset()>= input.getEnd()) return -1; input.substract(chunk.getBuffer(), 0, writeLength); chunk.setOffset(0); chunk.setEnd(writeLength); return writeLength; }
/** * Read bytes. */ @Override public int doRead(ByteChunk chunk, org.apache.coyote.Request request) throws IOException { int writeLength = 0; if (chunk.getLimit() > 0 && chunk.getLimit() < input.getLength()) { writeLength = chunk.getLimit(); } else { writeLength = input.getLength(); } if(input.getOffset()>= input.getEnd()) return -1; input.substract(chunk.getBuffer(), 0, writeLength); chunk.setOffset(0); chunk.setEnd(writeLength); return writeLength; }
/** * Read bytes. */ @Override public int doRead(ByteChunk chunk, org.apache.coyote.Request request) throws IOException { int writeLength = 0; if (chunk.getLimit() > 0 && chunk.getLimit() < input.getLength()) { writeLength = chunk.getLimit(); } else { writeLength = input.getLength(); } if(input.getOffset()>= input.getEnd()) return -1; input.substract(chunk.getBuffer(), 0, writeLength); chunk.setOffset(0); chunk.setEnd(writeLength); return writeLength; }
/** * Read bytes. */ @Override public int doRead(ByteChunk chunk, org.apache.coyote.Request request) throws IOException { int writeLength = 0; if (chunk.getLimit() > 0 && chunk.getLimit() < input.getLength()) { writeLength = chunk.getLimit(); } else { writeLength = input.getLength(); } if(input.getOffset()>= input.getEnd()) return -1; input.substract(chunk.getBuffer(), 0, writeLength); chunk.setOffset(0); chunk.setEnd(writeLength); return writeLength; }
public int realReadChars(char cbuf[], int off, int len) throws IOException { if (!gotEnc) setConverter(); if (bb.getLength() <= 0) { int nRead = realReadBytes(bb.getBytes(), 0, bb.getBytes().length); if (nRead < 0) { return -1; } } if (markPos == -1) { cb.setOffset(0); cb.setEnd(0); } int limit = bb.getLength()+cb.getStart(); if ( cb.getLimit() < limit ) cb.setLimit(limit); state = CHAR_STATE; conv.convert(bb, cb, bb.getLength()); bb.setOffset(bb.getEnd()); return cb.getLength(); }
public int realReadChars(char cbuf[], int off, int len) throws IOException { if (!gotEnc) setConverter(); if (bb.getLength() <= 0) { int nRead = realReadBytes(bb.getBytes(), 0, bb.getBytes().length); if (nRead < 0) { return -1; } } if (markPos == -1) { cb.setOffset(0); cb.setEnd(0); } int limit = bb.getLength()+cb.getStart(); if ( cb.getLimit() < limit ) cb.setLimit(limit); state = CHAR_STATE; conv.convert(bb, cb, bb.getLength()); bb.setOffset(bb.getEnd()); return cb.getLength(); }