Examples of FullHttpResponse


Examples of io.netty.handler.codec.http.FullHttpResponse

    @Test
    public void jsonpPollingTestClose() throws Exception {
        final String serviceName = "/close";
        final String sessionUrl = serviceName + "/222/" + UUID.randomUUID().toString();
        final SockJsServiceFactory service = closeService();
        final FullHttpResponse response = jsonpRequest(sessionUrl + "/jsonp?c=x", service);
        assertThat(response.content().toString(UTF_8), equalTo("x(\"o\");\r\n"));

        final FullHttpResponse firstResponse = jsonpRequest(sessionUrl + "/jsonp?c=x", service);
        assertThat(firstResponse.content().toString(UTF_8), equalTo("x(\"c[3000,\\\"Go away!\\\"]\");\r\n"));

        final FullHttpResponse secondResponse = jsonpRequest(sessionUrl + "/jsonp?c=x", service);
        assertThat(secondResponse.content().toString(UTF_8), equalTo("x(\"c[3000,\\\"Go away!\\\"]\");\r\n"));
    }
View Full Code Here

Examples of io.netty.handler.codec.http.FullHttpResponse

     */
    @Test
    public void jsessionIdCookieTestBasic() throws Exception {
        final SockJsConfig config = SockJsConfig.withPrefix("/cookie_needed_echo").cookiesNeeded().build();
        SockJsServiceFactory serviceFactory = echoService(config);
        final FullHttpResponse response = infoRequest(config.prefix(), serviceFactory);
        assertThat(response.getStatus(), is(HttpResponseStatus.OK));
        verifyNoSET_COOKIE(response);
        assertThat(infoAsJson(response).get("cookie_needed").asBoolean(), is(true));
    }
View Full Code Here

Examples of io.netty.handler.codec.http.FullHttpResponse

        removeLastInboundMessageHandlers(ch);
        final String sessionUrl = serviceName + "/abc/" + UUID.randomUUID().toString();
        final FullHttpRequest request = httpRequest(sessionUrl + Transports.Type.XHR.path(), GET);
        request.headers().set("Cookie", ClientCookieEncoder.encode("JSESSIONID", "abcdef"));
        ch.writeInbound(request);
        final FullHttpResponse response2 = ch.readOutbound();
        assertThat(response2.getStatus(), is(HttpResponseStatus.OK));
        assertSetCookie("abcdef", response2);
    }
View Full Code Here

Examples of io.netty.handler.codec.http.FullHttpResponse

    @Test
    public void jsonEncodingTestXhrServerEncodes() throws Exception {
        final SockJsServiceFactory echoFactory = echoService();
        final String sessionUrl = echoFactory.config().prefix() + "/abc/" + UUID.randomUUID().toString();

        final FullHttpResponse response = xhrRequest(sessionUrl, echoFactory);
        assertOpenFrameResponse(response);
        final String content = Transports.escapeCharacters(serverKillerStringEsc().toCharArray());
        final FullHttpResponse xhrSendResponse = xhrSendRequest(sessionUrl, "[\"" + content + "\"]", echoFactory);
        assertThat(xhrSendResponse.getStatus(), is(HttpResponseStatus.NO_CONTENT));
        final FullHttpResponse pollResponse = xhrRequest(sessionUrl, echoFactory);
        assertThat(pollResponse.getStatus(), is(HttpResponseStatus.OK));
        assertThat(pollResponse.content().toString(UTF_8), equalTo("a[\"" + content + "\"]\n"));
    }
View Full Code Here

Examples of io.netty.handler.codec.http.FullHttpResponse

    @Test
    public void jsonEncodingTestXhrServerDecodes() throws Exception {
        final SockJsServiceFactory echoFactory = echoService();
        final String sessionUrl = echoFactory.config().prefix() + "/abc/" + UUID.randomUUID().toString();

        final FullHttpResponse response = xhrRequest(sessionUrl, echoFactory);
        assertThat(response.getStatus(), is(HttpResponseStatus.OK));
        assertThat(response.content().toString(UTF_8), equalTo("o\n"));

        final String content = "[\"" + clientKillerStringEsc() + "\"]";
        final FullHttpResponse xhrSendResponse = xhrSendRequest(sessionUrl, content, echoFactory);
        assertThat(xhrSendResponse.getStatus(), is(HttpResponseStatus.NO_CONTENT));

        final FullHttpResponse pollResponse = xhrRequest(sessionUrl, echoFactory);
        assertThat(pollResponse.getStatus(), is(HttpResponseStatus.OK));

        // Let the content go through the MessageFrame to match what the response will go through.
        final MessageFrame messageFrame = new MessageFrame(JsonUtil.decode(content)[0]);
        String expectedContent = JsonUtil.encode(messageFrame.content().toString(UTF_8) + '\n');
        String responseContent = JsonUtil.encode(pollResponse.content().toString(UTF_8));
        assertThat(responseContent, equalTo(expectedContent));
    }
View Full Code Here

Examples of io.netty.handler.codec.http.FullHttpResponse

        final EmbeddedChannel ch = channelForService(echoFactory);
        removeLastInboundMessageHandlers(ch);
        ch.writeInbound(httpRequest(sessionUrl + Transports.Type.XHR.path(), GET));

        final FullHttpResponse response = ch.readOutbound();
        assertThat(response.getStatus(), is(HttpResponseStatus.OK));
        assertThat(response.content().toString(UTF_8), equalTo("o\n"));

        final EmbeddedChannel ch2 = channelForService(echoFactory);
        removeLastInboundMessageHandlers(ch2);
        ch2.writeInbound(httpRequest(sessionUrl + Transports.Type.XHR.path(), GET));
        final FullHttpResponse response2 = ch2.readOutbound();
        assertThat(response2.content().toString(UTF_8), equalTo("c[2010,\"Another connection still open\"]\n"));

        final EmbeddedChannel ch3 = channelForService(echoFactory);
        removeLastInboundMessageHandlers(ch3);
        ch3.writeInbound(httpRequest(sessionUrl + Transports.Type.XHR.path(), GET));

        final FullHttpResponse response3 = ch3.readOutbound();
        assertThat(response3.content().toString(UTF_8), equalTo("c[1002,\"Connection interrupted\"]\n"));
    }
View Full Code Here

Examples of io.netty.handler.codec.http.FullHttpResponse

        new XhrSendTransport(null);
    }

    @Test
    public void messageReceivedNoPayload() {
        final FullHttpResponse response = processHttpRequest(requestWithBody(null));
        assertThat(response.getStatus(), equalTo(HttpResponseStatus.INTERNAL_SERVER_ERROR));
        assertThat(response.getProtocolVersion(), equalTo(HttpVersion.HTTP_1_1));
        assertThat(response.content().toString(UTF_8), equalTo("Payload expected."));
    }
View Full Code Here

Examples of io.netty.handler.codec.http.FullHttpResponse

        assertThat(response.content().toString(UTF_8), equalTo("Payload expected."));
    }

    @Test
    public void messageReceivedNoPayloadHttpVersion1_0() {
        final FullHttpResponse response = processHttpRequest(requestWithBody(null, HttpVersion.HTTP_1_0));
        assertThat(response.getStatus(), equalTo(HttpResponseStatus.INTERNAL_SERVER_ERROR));
        assertThat(response.getProtocolVersion(), equalTo(HttpVersion.HTTP_1_0));
        assertThat(response.content().toString(UTF_8), equalTo("Payload expected."));
    }
View Full Code Here

Examples of io.netty.handler.codec.http.FullHttpResponse

    }

    @Test
    public void messageReceivedSimpleString() {
        final String body = "[\"some message\"]";
        final FullHttpResponse response = processHttpRequest(requestWithBody(body));
        assertThat(response.getStatus(), equalTo(HttpResponseStatus.NO_CONTENT));
        assertThat(response.getProtocolVersion(), equalTo(HttpVersion.HTTP_1_1));
        assertThat(response.content().capacity(), is(0));
        SockJsTestUtil.verifyDefaultResponseHeaders(response, Transports.CONTENT_TYPE_PLAIN);
    }
View Full Code Here

Examples of io.netty.handler.codec.http.FullHttpResponse

    }

    @Test
    public void messageReceivedJsonObject() {
        final String body = "[{\"firstName\": \"Fletch\"}]";
        final FullHttpResponse response = processHttpRequest(requestWithBody(body));
        assertThat(response.getStatus(), equalTo(HttpResponseStatus.NO_CONTENT));
        assertThat(response.getProtocolVersion(), equalTo(HttpVersion.HTTP_1_1));
        assertThat(response.content().capacity(), is(0));
        SockJsTestUtil.verifyDefaultResponseHeaders(response, Transports.CONTENT_TYPE_PLAIN);
    }
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.