/** * Skip data sent by the client. * * @param req * Servlet request * @throws IOException * I/O exception */ protected void skipData(HttpServletRequest req) throws IOException { log.trace("skipData {}", req); int length = req.getContentLength(); log.trace("Skipping {} bytes", length); IoBuffer data = IoBuffer.allocate(length); ServletUtils.copy(req, data.asOutputStream()); data.flip(); data.free(); data = null; log.trace("Skipped {} bytes", length); }
log.debug("Decoding request"); IoBuffer reqBuffer = IoBuffer.allocate(req.getContentLength()); ServletUtils.copy(req, reqBuffer.asOutputStream()); reqBuffer.flip(); RemotingPacket packet = (RemotingPacket) codecFactory.getRemotingDecoder().decode(reqBuffer);
log.debug("Request content length: {}", reqContentLength); IoBuffer reqBuffer = IoBuffer.allocate(reqContentLength); ServletUtils.copy(req, reqBuffer.asOutputStream()); reqBuffer.flip(); post.setEntity(new InputStreamEntity(reqBuffer.asInputStream(), reqContentLength));
IoBuffer buf = IoBuffer.allocate(input.available()); try { ServletUtils.copy(input, buf.asOutputStream()); buf.flip(); Input in = new Input(buf);
log.trace("Request content length: {}", length); final IoBuffer message = IoBuffer.allocate(length); ServletUtils.copy(req, message.asOutputStream()); message.flip(); RTMP rtmp = conn.getState();
/** * {@inheritDoc} */ @Override public OutputStream asOutputStream() { return buf.asOutputStream(); }
/** * {@inheritDoc} */ @Override public OutputStream asOutputStream() { return buf.asOutputStream(); }
@Override public OutputStream asOutputStream() { return buf.asOutputStream(); }
/** * Compress contents using zlib. */ public void compress() { IoBuffer tmp = IoBuffer.allocate(0); tmp.setAutoExpand(true); byte[] tmpData = new byte[data.limit()]; data.position(0); data.get(tmpData); try (DeflaterOutputStream deflater = new DeflaterOutputStream(tmp.asOutputStream(), new Deflater(Deflater.BEST_COMPRESSION))) { deflater.write(tmpData); deflater.finish(); } catch (IOException e) { //docs state that free is optional tmp.free(); throw new RuntimeException("could not compress data", e); } data.free(); data = tmp; data.flip(); prepareIO(); }
/** * Compress contents using zlib. */ public void compress() { IoBuffer tmp = IoBuffer.allocate(0); tmp.setAutoExpand(true); byte[] tmpData = new byte[data.limit()]; data.position(0); data.get(tmpData); try (DeflaterOutputStream deflater = new DeflaterOutputStream(tmp.asOutputStream(), new Deflater(Deflater.BEST_COMPRESSION))) { deflater.write(tmpData); deflater.finish(); } catch (IOException e) { //docs state that free is optional tmp.free(); throw new RuntimeException("could not compress data", e); } data.free(); data = tmp; data.flip(); prepareIO(); }