Package io.netty.buffer

Examples of io.netty.buffer.ByteBufOutputStream


        }
        response.getHeaders().set(HttpHeaders.Names.CONTENT_TYPE, "text/html");
        ByteBuf buffer = response.getChannel().alloc().buffer(1024);// 1KB initial length.
        PrintStream printStream = null;
        try {
            printStream = new PrintStream(new ByteBufOutputStream(buffer));
            error.printStackTrace(printStream);
            String errorPage = ERROR_HTML_TEMPLATE.replace(STACKTRACE_TEMPLATE_VARIABLE,
                                                           buffer.toString(Charset.defaultCharset()));
            response.writeString(errorPage);
        } finally {
View Full Code Here


        }

        buffer.writeInt(totalLength);

        // Copy stream to buffer
        long totalRead = ByteStreams.copy(in, new ByteBufOutputStream(buffer));

        if (totalLength != totalRead) {
          throw new IOException("invalid stream length");
        }
View Full Code Here

        int bodyLen = msg.readableBytes();
        int headerLen = CodedOutputStream.computeRawVarint32Size(bodyLen);
        out.ensureWritable(headerLen + bodyLen);

        CodedOutputStream headerOut =
                CodedOutputStream.newInstance(new ByteBufOutputStream(out));
        headerOut.writeRawVarint32(bodyLen);
        headerOut.flush();

        out.writeBytes(msg, msg.readerIndex(), bodyLen);
    }
View Full Code Here

    @Override
    protected void encode(ChannelHandlerContext ctx, Serializable msg, ByteBuf out) throws Exception {
        Attribute<ObjectOutputStream> oosAttr = ctx.attr(OOS);
        ObjectOutputStream oos = oosAttr.get();
        if (oos == null) {
            oos = newObjectOutputStream(new ByteBufOutputStream(out));
            ObjectOutputStream newOos = oosAttr.setIfAbsent(oos);
            if (newOos != null) {
                oos = newOos;
            }
        }
View Full Code Here

        private final ByteBuf outputBuffer;

        StreamOut(final MuxStream meta) {
            this.meta = meta;
            this.outputBuffer = PooledByteBufAllocator.DEFAULT.ioBuffer(0);
            this.output = new ByteBufOutputStream(outputBuffer);
        }
View Full Code Here

        private final CompositeByteBuf outputBuffer;

        StreamOut(final MuxStream meta) {
            this.meta = meta;
            this.outputBuffer = PooledByteBufAllocator.DEFAULT.compositeBuffer();
            this.output = new ByteBufOutputStream(outputBuffer);
        }
View Full Code Here

                this.url = new URI(newURL);
                setupConnection(outMessage, this.url, csPolicy);
                entity = outMessage.get(NettyHttpClientRequest.class);
                //reset the buffers
                outBuffer.clear();
                outputStream = new ByteBufOutputStream(outBuffer);

            } catch (URISyntaxException e) {
                throw new IOException(e);
            }
        }
View Full Code Here

            super(message, possibleRetransmit, isChunking, chunkThreshold, conduitName, url);
            csPolicy = getClient(message);
            entity  = message.get(NettyHttpClientRequest.class);
            int bufSize = csPolicy.getChunkLength() > 0 ? csPolicy.getChunkLength() : 16320;
            outBuffer = Unpooled.buffer(bufSize);
            outputStream = new ByteBufOutputStream(outBuffer);
        }
View Full Code Here

    @Override
    protected void encode(ChannelHandlerContext ctx, Serializable msg, ByteBuf out) throws Exception {
        Attribute<ObjectOutputStream> oosAttr = ctx.attr(OOS);
        ObjectOutputStream oos = oosAttr.get();
        if (oos == null) {
            oos = newObjectOutputStream(new ByteBufOutputStream(out));
            ObjectOutputStream newOos = oosAttr.setIfAbsent(oos);
            if (newOos != null) {
                oos = newOos;
            }
        }
View Full Code Here

  Netty4ClientHttpRequest(Bootstrap bootstrap, URI uri, HttpMethod method, int maxRequestSize) {
    this.bootstrap = bootstrap;
    this.uri = uri;
    this.method = method;
    this.body = new ByteBufOutputStream(Unpooled.buffer(maxRequestSize));
  }
View Full Code Here

TOP

Related Classes of io.netty.buffer.ByteBufOutputStream

Copyright © 2018 www.massapicom. 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.