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; }
@Nullable private static String toHeaderValue(MessageBytes value) { switch (value.getType()) { case MessageBytes.T_BYTES: { final ByteChunk chunk = value.getByteChunk(); return new String(chunk.getBuffer(), chunk.getOffset(), chunk.getLength(), StandardCharsets.US_ASCII); } case MessageBytes.T_CHARS: { final CharChunk chunk = value.getCharChunk(); return new String(chunk.getBuffer(), chunk.getOffset(), chunk.getLength()); } case MessageBytes.T_STR: { return value.getString(); } } return null; } }
@Nullable private static AsciiString toHeaderName(MessageBytes value) { switch (value.getType()) { case MessageBytes.T_BYTES: { final ByteChunk chunk = value.getByteChunk(); return new AsciiString(chunk.getBuffer(), chunk.getOffset(), chunk.getLength(), true); } case MessageBytes.T_CHARS: { final CharChunk chunk = value.getCharChunk(); return new AsciiString(chunk.getBuffer(), chunk.getOffset(), chunk.getLength()); } case MessageBytes.T_STR: { return HttpHeaderNames.of(value.getString()); } } return null; }
/** * Returns the message bytes. */ public byte[] getBytes() { return getBuffer(); }
/** * Returns the message bytes. */ public byte[] getBytes() { return getBuffer(); }
/** * @return the buffer. */ public byte[] getBytes() { return getBuffer(); }
/** * Returns the message bytes. */ public byte[] getBytes() { return getBuffer(); }
/** * Returns the message bytes. */ public byte[] getBytes() { return getBuffer(); }
/** * Returns the message bytes. */ public byte[] getBytes() { return getBuffer(); }
private byte[] parseBase64() throws IllegalArgumentException { byte[] decoded = Base64.decodeBase64( authorization.getBuffer(), base64blobOffset, base64blobLength); // restore original offset authorization.setOffset(initialOffset); if (decoded == null) { throw new IllegalArgumentException( "Basic Authorization credentials are not Base64"); } return decoded; }
private byte[] parseBase64() throws IllegalArgumentException { byte[] decoded = Base64.decodeBase64( authorization.getBuffer(), base64blobOffset, base64blobLength); // restore original offset authorization.setOffset(initialOffset); if (decoded == null) { throw new IllegalArgumentException( "Basic Authorization credentials are not Base64"); } return decoded; }
private byte[] parseBase64() throws IllegalArgumentException { byte[] decoded = Base64.decodeBase64( authorization.getBuffer(), base64blobOffset, base64blobLength); // restore original offset authorization.setOffset(initialOffset); if (decoded == null) { throw new IllegalArgumentException( "Basic Authorization credentials are not Base64"); } return decoded; }
public void recycle() { if (buffered.getBuffer().length > 65536) { buffered = null; } else { buffered.recycle(); } tempRead.recycle(); hasRead = false; buffer = null; }
public void recycle() { if (buffered != null) { if (buffered.getBuffer().length > 65536) { buffered = null; } else { buffered.recycle(); } } tempRead.recycle(); hasRead = false; buffer = null; }
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); } }
/** * Write chunk. */ @Override public int doWrite(ByteChunk chunk, Response res) throws IOException { int len = chunk.getLength(); int start = chunk.getStart(); byte[] b = chunk.getBuffer(); addToBB(b, start, len); byteCount += chunk.getLength(); return chunk.getLength(); }
/** * Write chunk. */ @Override public int doWrite(ByteChunk chunk, Response res) throws IOException { int len = chunk.getLength(); int start = chunk.getStart(); byte[] b = chunk.getBuffer(); addToBB(b, start, len); byteCount += chunk.getLength(); return chunk.getLength(); }