Package org.jboss.netty.buffer

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


    }

    if (nettyRequest.headers().contains(HttpHeaders.Names.CONTENT_LENGTH)) {
      byte data[] = new byte[(int) HttpHeaders.getContentLength(nettyRequest)];
      ChannelBuffer content = nettyRequest.getContent();
      content.readBytes(data);
      request.setTextContent(new String(data, "UTF-8"));
    }

    LOGGER.trace("HTTP: " + request.getArgument() + " / " + request.getLowRange() + "-" + request.getHighRange());
View Full Code Here


        ChannelBuffer b = chunk != null ? chunk.getContent() : response.getContent();
        int read = b.readableBytes();
        int index = b.readerIndex();

        byte[] rb = new byte[read];
        b.readBytes(rb);
        bytes.set(rb);
        b.readerIndex(index);       
        return bytes.get();
    }
View Full Code Here

    public int writeTo(OutputStream outputStream) throws IOException {
        ChannelBuffer b = chunk != null ? chunk.getContent() : response.getContent();
        int read = b.readableBytes();
        int index = b.readerIndex();
        if (read > 0) {
            b.readBytes(outputStream, read);
        }
        b.readerIndex(index);
        return read;
    }
View Full Code Here

              isEarlyTerminated = content.readableBytes() < message.getPreviewAmount();
            }
          while(content.readableBytes() > 0) {
            IcapChunk chunk = null;
            if(content.readableBytes() > chunkSize) {
              chunk = new DefaultIcapChunk(content.readBytes(chunkSize));
            } else {
              chunk = new DefaultIcapChunk(content.readBytes(content.readableBytes()));
            }
            chunk.setPreviewChunk(isPreview);
            chunk.setEarlyTermination(isEarlyTerminated);
View Full Code Here

          while(content.readableBytes() > 0) {
            IcapChunk chunk = null;
            if(content.readableBytes() > chunkSize) {
              chunk = new DefaultIcapChunk(content.readBytes(chunkSize));
            } else {
              chunk = new DefaultIcapChunk(content.readBytes(content.readableBytes()));
            }
            chunk.setPreviewChunk(isPreview);
            chunk.setEarlyTermination(isEarlyTerminated);
            fireDownstreamEvent(ctx,chunk,msgEvent);
            if(chunk.isLast() | content.readableBytes() <= 0) {
View Full Code Here

                if (outputStream == null) {
                    awaitingEvents.add(e);
                    return;
                }
                b = new byte[buffer.readableBytes()];
                buffer.readBytes(b);
                outputStream.write(b);
                outputStream.flush();
                success = true;
            } catch (Exception ex) {
                success = false;
View Full Code Here

            this.outputStream = outputStream;
            connected = true;
            for (MessageEvent awaitingEvent : awaitingEvents) {
                ChannelBuffer buffer = (ChannelBuffer) awaitingEvent.getMessage();
                byte[] b = new byte[buffer.readableBytes()];
                buffer.readBytes(b);
                outputStream.write(b);
                outputStream.flush();
            }
            reconnectCondition.signalAll();
        }
View Full Code Here

        response.setContentLength(length);
        response.setStatus(HttpServletResponse.SC_OK);
        for (MessageEvent event: buffers) {
            ChannelBuffer buffer = (ChannelBuffer) event.getMessage();
            byte[] b = new byte[buffer.readableBytes()];
            buffer.readBytes(b);
            try {
                response.getOutputStream().write(b);
                event.getFuture().setSuccess();
            } catch (IOException e) {
                event.getFuture().setFailure(e);
View Full Code Here

        builder.unsafeAddHeaderValue(e.getKey(), e.getValue());
      }

      ChannelBuffer buf = nettyResponse.getContent();
      byte[] array = new byte[buf.readableBytes()];
      buf.readBytes(array);
      builder.setEntity(array);

      return builder.build();
    }
  }
View Full Code Here

            // ignore
            msg.readByte();
            int status = msg.readByte();
            int port = msg.readShort();
            byte[] addr = new byte[4];
            msg.readBytes(addr);

            ctx.getChannel().setAttachment(new InetSocketAddress(InetAddress.getByAddress(addr), port));

            if (status == SocksProtocols.REQUEST_GRANTED) {
                ctx.getPipeline().remove(Socks4ClientBootstrap.FRAME_DECODER);
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.