Refine search
/** * 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); }
if (reqContentLength > 0) { 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)); post.addHeader("Content-Type", REQUEST_TYPE); resultBuffer.flip(); ServletUtils.copy(resultBuffer.asInputStream(), resp.getOutputStream()); resp.flushBuffer();
private void deliverRawText0(String text){ boolean errorDelivering = false; IoBuffer buffer = IoBuffer.allocate(text.length()); buffer.setAutoExpand(true); try { //Charset charset = Charset.forName(CHARSET); //buffer.putString(text, charset.newEncoder()); buffer.put(text.getBytes(StandardCharsets.UTF_8)); if (flashClient) { buffer.put((byte) '\0'); } buffer.flip(); ioSessionLock.lock(); try { ioSession.write(buffer); } finally { ioSessionLock.unlock(); } } catch (Exception e) { Log.debug("Error delivering raw text:\n" + text, e); errorDelivering = true; } // Attempt to close the connection if delivering text fails. if (errorDelivering) { close(); } }
/** {@inheritDoc} */ @Override public void messageReceived(NextFilter next, IoSession session, Object message) throws Exception { if (message instanceof IoBuffer) { IoBuffer out = (IoBuffer) message; if (headers != null) { IoBuffer header = IoBuffer.allocate(12); header.putLong(System.currentTimeMillis()); header.putInt(out.limit() - out.position()); header.flip(); headers.write(header.buf()); } if (raw != null) { raw.write(out.asReadOnlyBuffer().buf()); } } next.messageReceived(session, message); }
/** {@inheritDoc} */ @Override public void messageReceived(NextFilter next, IoSession session, Object message) throws Exception { // Create forwarding IO session IoSession forward = (IoSession) session.getAttribute(FORWARD_KEY); if (forward != null && forward.isConnected()) { if (message instanceof IoBuffer) { final IoBuffer buf = (IoBuffer) message; if (log.isDebugEnabled()) { log.debug("[{}] RAW >> {}", name, buf.getHexDump()); } IoBuffer copy = IoBuffer.allocate(buf.limit()); int limit = buf.limit(); copy.put(buf); copy.flip(); forward.write(copy); buf.flip(); buf.position(0); buf.limit(limit); } } next.messageReceived(session, message); }
WritableByteChannel headers = headersFos.getChannel(); WritableByteChannel raw = rawFos.getChannel(); IoBuffer header = IoBuffer.allocate(1); header.put((byte) (isClient ? 0x00 : 0x01)); header.flip(); headers.write(header.buf()); session.getFilterChain().addFirst("dump", new NetworkDumpFilter(headers, raw));
@Override public void encode(IoSession session, Object message, ProtocolEncoderOutput out) { IoBuffer buf = IoBuffer.allocate( 1024 ); DnsMessage dnsMessage = (DnsMessage) message; encoder.encode(buf, dnsMessage); for (ResourceRecord record: dnsMessage.getAnswerRecords()) { // This is a hack to allow to also test for AAAA resolution as DnsMessageEncoder does not support it and it // is hard to extend, because the interesting methods are private... // In case of RecordType.AAAA we need to encode the RecordType by ourself if (record.getRecordType() == RecordType.AAAA) { try { recordEncoder.put(buf, record); } catch (IOException e) { // Should never happen throw new IllegalStateException(e); } } } buf.flip(); out.write( buf ); } };
/** * Generates response for non-versioned connections, such as those before FP9. * * @param input * incoming RTMP bytes * @return outgoing handshake */ private IoBuffer generateUnversionedHandshake(byte[] input) { log.debug("Using old style (un-versioned) handshake"); IoBuffer output = IoBuffer.allocate((Constants.HANDSHAKE_SIZE * 2) + 1); // 3073 // non-encrypted output.put(RTMPConnection.RTMP_NON_ENCRYPTED); // set server uptime in seconds output.putInt((int) Red5.getUpTime() / 1000); //0x01 output.position(Constants.HANDSHAKE_SIZE + 1); output.put(input); output.flip(); // fill S1 with handshake data (nearly all 0's) output.mark(); output.position(1); output.get(s1); output.reset(); return output; }
@Override public void encode(IoSession session, Object message, ProtocolEncoderOutput out) { IoBuffer buf = IoBuffer.allocate( 1024 ); DnsMessage dnsMessage = (DnsMessage) message; encoder.encode(buf, dnsMessage); for (ResourceRecord record: dnsMessage.getAnswerRecords()) { // This is a hack to allow to also test for AAAA resolution as DnsMessageEncoder does not support it and it // is hard to extend, because the interesting methods are private... // In case of RecordType.AAAA we need to encode the RecordType by ourself if (record.getRecordType() == RecordType.AAAA) { try { recordEncoder.put(buf, record); } catch (IOException e) { // Should never happen throw new IllegalStateException(e); } } } buf.flip(); out.write( buf ); } };
public BitRequest ( final byte area, final short block, final short start, final boolean[] bits ) { super ( AddressType.BIT, area, block, start, (short)bits.length ); this.data = IoBuffer.allocate ( bits.length ); for ( int i = 0; i < bits.length; i++ ) { this.data.put ( bits[i] ? (byte)0x01 : (byte)0x00 ); } this.data.flip (); }