Package io.netty.buffer

Examples of io.netty.buffer.ByteBuf.readerIndex()


        if (read == 0) {
            return EMPTY_BUFFER;
        }
        byteBuffer.flip();
        ByteBuf buffer = wrappedBuffer(byteBuffer);
        buffer.readerIndex(0);
        buffer.writerIndex(read);
        return buffer;
    }

    @Override
View Full Code Here


    }

    // if log level permits it (= DEBUG level or lower), log all the bytes that will be written
    if (LOGGER.isDebugEnabled() && !this.logBlackList.contains(outgoingPacketClass)) {
     
      int currentReaderIndex = buffer.readerIndex();
      // Prepare a StringBuilder that will build the final log line (efficiently)
      StringBuilder sb = new StringBuilder("Bytes (").append(buffer.writerIndex()).append("): ");
      // Write all bytes that were written to this ByteBuffer to the StringBuilder
      while (buffer.isReadable()) {
        sb.append(String.format("%02X ", buffer.readByte()));
View Full Code Here

      StringBuilder sb = new StringBuilder("Bytes (").append(buffer.writerIndex()).append("): ");
      // Write all bytes that were written to this ByteBuffer to the StringBuilder
      while (buffer.isReadable()) {
        sb.append(String.format("%02X ", buffer.readByte()));
      }
      buffer.readerIndex(currentReaderIndex);
      // Print the final log
      LOGGER.debug(sb.toString());
    }

    return buffer;
View Full Code Here

                        "HTTP content length exceeded " + maxContentLength + " bytes.");
            }

            ByteBuf spdyDataFrameData = spdyDataFrame.content();
            int spdyDataFrameDataLen = spdyDataFrameData.readableBytes();
            content.writeBytes(spdyDataFrameData, spdyDataFrameData.readerIndex(), spdyDataFrameDataLen);

            if (spdyDataFrame.isLast()) {
                HttpHeaderUtil.setContentLength(fullHttpMessage, content.readableBytes());
                removeMessage(streamId);
                out.add(fullHttpMessage);
View Full Code Here

  private ParseState state = ParseState.MAGIC1;

  @Override
  public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
    ByteBuf buffer = (ByteBuf) msg;
    int index = buffer.readerIndex();
    switch (state) {
      case MAGIC1:
        if (!buffer.isReadable()) {
          return;
        }
View Full Code Here

     */
    @Override
    public List<String> decode(DnsResponse response, DnsResource resource) {
        List<String> list = new ArrayList<String>();
        ByteBuf data = resource.content().readerIndex(response.originalIndex());
        int index = data.readerIndex();
        while (index < data.writerIndex()) {
            int len = data.getUnsignedByte(index++);
            list.add(data.toString(index, len, CharsetUtil.UTF_8));
            index += len;
        }
View Full Code Here

     *            the {@link DnsResource} being decoded
     */
    @Override
    public InetAddress decode(DnsResponse response, DnsResource resource) {
        ByteBuf data = resource.content().copy().readerIndex(response.originalIndex());
        int size = data.writerIndex() - data.readerIndex();
        if (data.readerIndex() != 0 || size != octets) {
            throw new DecoderException("Invalid content length, or reader index when decoding address [index: "
                    + data.readerIndex() + ", expected length: " + octets + ", actual: " + size + "].");
        }
        byte[] address = new byte[octets];
View Full Code Here

     */
    @Override
    public InetAddress decode(DnsResponse response, DnsResource resource) {
        ByteBuf data = resource.content().copy().readerIndex(response.originalIndex());
        int size = data.writerIndex() - data.readerIndex();
        if (data.readerIndex() != 0 || size != octets) {
            throw new DecoderException("Invalid content length, or reader index when decoding address [index: "
                    + data.readerIndex() + ", expected length: " + octets + ", actual: " + size + "].");
        }
        byte[] address = new byte[octets];
        data.getBytes(data.readerIndex(), address);
View Full Code Here

    public InetAddress decode(DnsResponse response, DnsResource resource) {
        ByteBuf data = resource.content().copy().readerIndex(response.originalIndex());
        int size = data.writerIndex() - data.readerIndex();
        if (data.readerIndex() != 0 || size != octets) {
            throw new DecoderException("Invalid content length, or reader index when decoding address [index: "
                    + data.readerIndex() + ", expected length: " + octets + ", actual: " + size + "].");
        }
        byte[] address = new byte[octets];
        data.getBytes(data.readerIndex(), address);
        try {
            return InetAddress.getByAddress(address);
View Full Code Here

        if (data.readerIndex() != 0 || size != octets) {
            throw new DecoderException("Invalid content length, or reader index when decoding address [index: "
                    + data.readerIndex() + ", expected length: " + octets + ", actual: " + size + "].");
        }
        byte[] address = new byte[octets];
        data.getBytes(data.readerIndex(), address);
        try {
            return InetAddress.getByAddress(address);
        } catch (UnknownHostException e) {
            throw new DecoderException("Could not convert address "
                    + data.toString(data.readerIndex(), size, CharsetUtil.UTF_8) + " to InetAddress.");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.