Examples of readableBytes()


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

    @Override
    public void close(final AtmosphereResponse response) throws IOException {
        if (!channel.isOpen() || doneProcessing.get()) return;

        ChannelBuffer writeBuffer = writeHeaders(response);
        if (writeBuffer.readableBytes() > 0 && response != null) {
            final AtomicReference<ChannelBuffer> recycle = new AtomicReference<ChannelBuffer>(writeBuffer);
            try {
                lock.writeLock().lock();
                channel.write(writeBuffer).addListener(new ChannelFutureListener() {
                    @Override
View Full Code Here

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

      if (e.getMessage() instanceof ChannelBuffer)
      {
        ChannelBuffer bufferMessage = (ChannelBuffer)e.getMessage();
        if (null == _connStatsCollector)
        {
          _statsCollector.addInboundResponseSize(bufferMessage.readableBytes());
        }
        else
        {
          _connStatsCollector.addInboundResponseSize(bufferMessage.readableBytes());
View Full Code Here

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

        {
          _statsCollector.addInboundResponseSize(bufferMessage.readableBytes());
        }
        else
        {
          _connStatsCollector.addInboundResponseSize(bufferMessage.readableBytes());

          if (_unmergedEventsNum >= MAX_UNMERGED_EVENTS_NUM)
          {
            mergeConnStats();
          }
View Full Code Here

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

  @Override
  public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception
  {
    _response = (HttpResponse) e.getMessage();
    ChannelBuffer content = _response.getContent();
    _receivedBytes = new byte[content.readableBytes()];
    content.getBytes(0, _receivedBytes);
    _lock.lock();
    try
    {
      _hasResponse = true;
View Full Code Here

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

          // Merge the received chunk into the content of the current message.
          HttpChunk chunk = (HttpChunk) msg;
          ChannelBuffer content = currentMessage.getContent();

          if (content.readableBytes() > maxContentLength - chunk.getContent().readableBytes()) {
              throw new TooLongFrameException(
                      "HTTP content length exceeded " + maxContentLength +
                      " bytes.");
          }
View Full Code Here

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

          content.writeBytes(chunk.getContent());
          if (chunk.isLast()) {
              this.currentMessage = null;
              currentMessage.setHeader(
                      HttpHeaders.Names.CONTENT_LENGTH,
                      String.valueOf(content.readableBytes()));
             
              if (chunk instanceof HttpChunkTrailer)
              {
                HttpChunkTrailer chunkTrailer = (HttpChunkTrailer)chunk;
                for(Entry<String, String> footer: chunkTrailer.getHeaders())
View Full Code Here

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

            return;     
    }
   
    ChannelBuffer cb = ChannelBuffers.copiedBuffer(message.toString(), CharsetUtil.UTF_8);
    HttpResponse response = new DefaultHttpResponse(HTTP_1_1, OK);
    response.setHeader(CONTENT_LENGTH, cb.readableBytes());
    response.setHeader(CONTENT_TYPE, "application/json");
    response.setHeader(CACHE_CONTROL, "no-cache");
    response.setContent(cb);
    ChannelFuture cf = Channels.future(channel);
    ctx.sendDownstream(new DownstreamMessageEvent(channel, cf, response, channel.getRemoteAddress()));
View Full Code Here

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

  protected Object encode(ChannelHandlerContext context, Channel channel,  Object message) throws Exception {
    ChannelBuffer content = (ChannelBuffer) message;
    HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, uri);
    request.setHeader(HttpHeaders.Names.HOST, host);
    request.setHeader(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE);
    request.setHeader(HttpHeaders.Names.CONTENT_LENGTH, content.readableBytes());
    request.setContent(content);
    return request;
  }

}
View Full Code Here

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

        if (message instanceof DefaultHttpResponse) {
            cb = (ChannelBuffer) ((DefaultHttpResponse) message).getContent();
        } else {
            cb = (ChannelBuffer) message;
        }
        while (cb.readableBytes() > 0) {
            peer.offer(cb.readByte());
        }
    }
}
View Full Code Here

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

        processor.process(protocol, protocol);

        if (httpRequest != null) {
            HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
            response.setHeader("Content-Length", output.readableBytes());
            response.setContent(output);
            ChannelFuture future = e.getChannel().write(response);
            if (!HttpHeaders.isKeepAlive(httpRequest)) {
                future.addListener(ChannelFutureListener.CLOSE);
            }
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.