Examples of content()


Examples of io.netty.channel.udt.UdtMessage.content()

    @Override
    protected boolean doWriteMessage(Object msg, ChannelOutboundBuffer in) throws Exception {
        // expects a message
        final UdtMessage message = (UdtMessage) msg;

        final ByteBuf byteBuf = message.content();

        final int messageSize = byteBuf.readableBytes();

        final long writtenBytes;
        if (byteBuf.nioBufferCount() == 1) {
View Full Code Here

Examples of io.netty.handler.codec.http.DefaultFullHttpRequest.content()

            final ByteBuf byteBuf = Unpooled.copiedBuffer("d=", UTF_8);
            r.content().writeBytes(byteBuf);
            byteBuf.release();
        } else {
            final ByteBuf byteBuf = Unpooled.copiedBuffer("d=" + data, UTF_8);
            r.content().writeBytes(byteBuf);
            byteBuf.release();
        }
        return r;
    }
View Full Code Here

Examples of io.netty.handler.codec.http.DefaultFullHttpResponse.content()

        // when
        DefaultFullHttpResponse defaultFullHttpResponse = new MockServerToNettyResponseMapper().mapMockServerResponseToNettyResponse(httpResponse);

        // then
        assertEquals(HttpStatusCode.OK_200.code(), defaultFullHttpResponse.getStatus().code());
        assertEquals("somebody", defaultFullHttpResponse.content().toString(Charsets.UTF_8));
        assertEquals("headerValue1", defaultFullHttpResponse.headers().get("headerName1"));
        assertThat(defaultFullHttpResponse.headers().getAll("headerName2"), containsInAnyOrder("headerValue2_1", "headerValue2_2"));
        assertEquals(Arrays.asList(
                "cookieName1=cookieValue1",
                "cookieName2=cookieValue2"
View Full Code Here

Examples of io.netty.handler.codec.http.DefaultHttpContent.content()

        assertThat(response.getStatus(), equalTo(HttpResponseStatus.OK));
        assertThat(response.headers().get(CONTENT_TYPE), equalTo(EventSourceTransport.CONTENT_TYPE_EVENT_STREAM));
        SockJsTestUtil.verifyNoCacheHeaders(response);

        final DefaultHttpContent newLinePrelude = ch.readOutbound();
        assertThat(newLinePrelude.content().toString(UTF_8), equalTo("\r\n"));
        final DefaultHttpContent data = ch.readOutbound();
        assertThat(data.content().toString(UTF_8), equalTo("data: o\r\n\r\n"));
    }

    private static EmbeddedChannel newEventSourceChannel() {
View Full Code Here

Examples of io.netty.handler.codec.http.FullHttpMessage.content()

                    fullHttpMessage.headers().add(e.getKey(), e.getValue());
                }
            }

            if (spdyHeadersFrame.isLast()) {
                HttpHeaders.setContentLength(fullHttpMessage, fullHttpMessage.content().readableBytes());
                removeMessage(streamId);
                out.add(fullHttpMessage);
            }

        } else if (msg instanceof SpdyDataFrame) {
View Full Code Here

Examples of io.netty.handler.codec.http.FullHttpRequest.content()

                msg = exchange.getIn(NettyHttpMessage.class);
            }
            if (msg != null && msg.getBody() == value) {
                // ensure the http request content is reset so we can read all the content out-of-the-box
                FullHttpRequest request = msg.getHttpRequest();
                request.content().resetReaderIndex();
                return request;
            }
        }

        return null;
View Full Code Here

Examples of io.netty.handler.codec.http.FullHttpResponse.content()

            }
            active = true;
            handShakeFuture.run();
         }
         waitingGet = false;
         ctx.fireChannelRead(response.content());
      }

      @Override
      public void write(final ChannelHandlerContext ctx, final Object msg, ChannelPromise promise) throws Exception
      {
View Full Code Here

Examples of io.netty.handler.codec.http.HttpContent.content()

            // store handler as attachment
            attr.set(handler);
            if (msg instanceof HttpContent) {
                // need to hold the reference of content
                HttpContent httpContent = (HttpContent) msg;
                httpContent.content().retain();
            }  
            handler.channelRead(ctx, request);
        } else {
            // this resource is not found, so send empty response back
            HttpResponse response = new DefaultHttpResponse(HTTP_1_1, NOT_FOUND);
View Full Code Here

Examples of io.netty.handler.codec.http.LastHttpContent.content()

            assertThat(validSend.getStatus(), is(HttpResponseStatus.NO_CONTENT));
            final DefaultHttpContent chunk = ch.readOutbound();
            assertThat(chunk.content().toString(UTF_8), equalTo("a[\"" + msg + "\"]\n"));
        }
        final LastHttpContent lastChunk = ch.readOutbound();
        assertThat(lastChunk.content().readableBytes(), is(0));
        assertThat(ch.isOpen(), is(false));
    }

    /*
     * Equivalent to EventSource.test_response_limit in sockjs-protocol-0.3.3.py.
View Full Code Here

Examples of io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame.content()

    @Override
    protected void decode(final ChannelHandlerContext channelHandlerContext, final WebSocketFrame webSocketFrame, final List<Object> objects) throws Exception {
        try {
            if (webSocketFrame instanceof BinaryWebSocketFrame) {
                final BinaryWebSocketFrame tf = (BinaryWebSocketFrame) webSocketFrame;
                objects.add(serializer.deserializeResponse(tf.content()));
            } else {
                final TextWebSocketFrame tf = (TextWebSocketFrame) webSocketFrame;
                final MessageTextSerializer textSerializer = (MessageTextSerializer) serializer;
                objects.add(textSerializer.deserializeResponse(tf.text()));
            }
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.