Package org.jboss.netty.buffer

Examples of org.jboss.netty.buffer.ChannelBuffer.readerIndex()


    assertEquals("The body content was wrong",builder.toString(),body)
    embedder.offer(DataMockery.createRESPMODWithGetRequestAndPreviewIcapChunkFullMessageChunk());
    embedder.offer(DataMockery.createRESPMODWithGetRequestAndPreviewChunkTrailer());
    IcapRequest request1 = (IcapRequest)embedder.poll();
    buffer = request1.getHttpResponse().getContent();
    Assert.assertEquals("wrong reader index",0,buffer.readerIndex());
    String body1 = destructiveRead(buffer);
    assertEquals("The body content after another chunk was sent is wrong","This is data that was returned by an origin server.And this the second chunk which contains more information.",body1);
    Object object = embedder.peek();
    assertNull("still something there",object)
  }
View Full Code Here


      header = IcapDecoderUtil.readSingleHeaderLine(buffer,sizeDelimiter);
      assertEquals("Host header was expected","Host: icap.mimo.ch",header);
      assertEquals("total length of parsed headers is wrong",75,sizeDelimiter.getSize());
      header = IcapDecoderUtil.readSingleHeaderLine(buffer,sizeDelimiter);
      assertEquals("header length is not null",0,header.length());
      byte bite = buffer.getByte(buffer.readerIndex());
      assertEquals("...",'G',(char)bite);
    } catch (DecodingException e) {
      e.printStackTrace();
      fail();
    }
View Full Code Here

          if(content.readableBytes() > maxContentLength - chunkBuffer.readableBytes()) {
            throw new TooLongFrameException("ICAP content length exceeded [" + maxContentLength + "] bytes");
          } else {
            content.writeBytes(chunkBuffer);
            if(resetReaderIndex) {
              content.readerIndex(READER_INDEX_RESET_VALUE);
            }
          }
        }
      } else {
        ctx.sendUpstream(e);
View Full Code Here

                ChannelBuffer a;
                if (channel.currentWriteEvent == null) {
                    channel.currentWriteEvent = channel.writeBuffer.poll();
                    a = (ChannelBuffer) channel.currentWriteEvent.getMessage();
                    channel.currentWriteIndex = a.readerIndex();
                } else {
                    a = (ChannelBuffer) channel.currentWriteEvent.getMessage();
                }

                int localWrittenBytes = 0;
View Full Code Here

            Object message) {
        OutputStream out = channel.getOutputStream();
        try {
            ChannelBuffer a = (ChannelBuffer) message;
            synchronized (out) {
                a.getBytes(a.readerIndex(), out, a.readableBytes());
            }
            future.setSuccess();
        } catch (Throwable t) {
            future.setFailure(t);
            fireExceptionCaught(channel, t);
View Full Code Here

        }

        // Otherwise, all messages are encrypted.
        ChannelBuffer msg = (ChannelBuffer) e.getMessage();
        PendingWrite pendingWrite =
            new PendingWrite(evt.getFuture(), msg.toByteBuffer(msg.readerIndex(), msg.readableBytes()));
        synchronized (pendingUnencryptedWrites) {
            pendingUnencryptedWrites.offer(pendingWrite);
        }

        wrap(context, evt.getChannel());
View Full Code Here

    @Override
    public byte[] bodyAsBytes() {
        ChannelBuffer buffer = httpRequest.getContent();
        byte[] body = new byte[buffer.readableBytes()];
        buffer.getBytes(buffer.readerIndex(), body);
        return body;
    }

    @Override
    public Map<String, Object> data() {
View Full Code Here

        // Otherwise, all messages are encrypted.
        ChannelBuffer msg = (ChannelBuffer) e.getMessage();
        PendingWrite pendingWrite;

        if (msg.readable()) {
            pendingWrite = new PendingWrite(evt.getFuture(), msg.toByteBuffer(msg.readerIndex(), msg.readableBytes()));
        } else {
            pendingWrite = new PendingWrite(evt.getFuture(), null);
        }

        pendingUnencryptedWritesLock.lock();
View Full Code Here

                        removeOpWrite = true;
                        break;
                    }

                    buf = (ChannelBuffer) evt.getMessage();
                    bufIdx = buf.readerIndex();
                } else {
                    buf = (ChannelBuffer) evt.getMessage();
                    bufIdx = channel.currentWriteIndex;
                }
View Full Code Here

        OutputStream out = channel.getOutputStream();
        try {
            ChannelBuffer a = (ChannelBuffer) message;
            int bytes = a.readableBytes();
            synchronized (out) {
                a.getBytes(a.readerIndex(), out, bytes);
            }
            fireWriteComplete(channel, bytes);
            future.setSuccess();
        } catch (Throwable t) {
            // Convert 'SocketException: Socket closed' to
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.