Examples of FullHttpResponse


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

        final DefaultHttpContent openResponse = ch.readOutbound();
        assertThat(openResponse.content().toString(UTF_8), equalTo("o\n"));

        final String msg = generateMessage(128);
        for (int i = 0; i < 31; i++) {
            final FullHttpResponse validSend = xhrSendRequest(sessionUrl, "[\"" + msg + "\"]", echoFactory);
            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));
View Full Code Here

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

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

        final String msg = generateMessage(4096);
        final FullHttpResponse validSend = xhrSendRequest(sessionUrl, "[\"" + msg + "\"]", echoFactory);
        assertThat(validSend.getStatus(), is(HttpResponseStatus.NO_CONTENT));
        final DefaultHttpContent chunk = ch.readOutbound();
        assertThat(chunk.content().toString(UTF_8), equalTo("data: a[\"" + msg + "\"]\r\n\r\n"));

        assertThat(ch.isOpen(), is(false));
    }
View Full Code Here

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

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

        final String msg = "[\"  \\u0000\\n\\r \"]";
        final FullHttpResponse validSend = xhrSendRequest(sessionUrl, msg, echoFactory);
        assertThat(validSend.getStatus(), is(HttpResponseStatus.NO_CONTENT));

        final DefaultHttpContent chunk = ch.readOutbound();
        assertThat(chunk.content().toString(UTF_8), equalTo("data: a[\"  \\u0000\\n\\r \"]\r\n\r\n"));
    }
View Full Code Here

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

        final String header = headerChunk.content().toString(UTF_8);
        assertThat(header, containsString("var c = parent.callback"));
        final HttpContent openChunk = ch.readOutbound();
        assertThat(openChunk.content().toString(UTF_8), equalTo("<script>\np(\"o\");\n</script>\r\n"));

        final FullHttpResponse validSend = xhrSendRequest(sessionUrl, "[\"x\"]", service);
        assertThat(validSend.getStatus(), is(HttpResponseStatus.NO_CONTENT));

        final DefaultHttpContent messageChunk = ch.readOutbound();
        assertThat(messageChunk.content().toString(UTF_8), equalTo("<script>\np(\"a[\\\"x\\\"]\");\n</script>\r\n"));
        ch.finish();
    }
View Full Code Here

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

        final EmbeddedChannel ch = channelForService(service);
        removeLastInboundMessageHandlers(ch);

        final FullHttpRequest request = httpRequest(sessionUrl + Transports.Type.HTMLFILE.path() + "?c=", GET);
        ch.writeInbound(request);
        final FullHttpResponse response =  ch.readOutbound();
        assertThat(response.getStatus(), equalTo(HttpResponseStatus.INTERNAL_SERVER_ERROR));
        assertThat(response.content().toString(UTF_8), equalTo("\"callback\" parameter required"));
    }
View Full Code Here

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

        ch.readOutbound();
        // read and discard open frame
        ch.readOutbound();

        final String msg = generateMessage(4096);
        final FullHttpResponse validSend = xhrSendRequest(sessionUrl, "[\"" + msg + "\"]", service);
        assertThat(validSend.getStatus(), is(HttpResponseStatus.NO_CONTENT));
        final DefaultHttpContent chunk = ch.readOutbound();
        assertThat(chunk.content().toString(UTF_8), equalTo("<script>\np(\"a[\\\"" + msg + "\\\"]\");\n</script>\r\n"));

        assertThat(ch.isOpen(), is(false));
    }
View Full Code Here

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

    public void jsonpPollingTestTransport() throws Exception {
        final String serviceName = "/echo";
        final String sessionUrl = serviceName + "/222/" + UUID.randomUUID().toString();
        final SockJsServiceFactory echoService = echoService();

        final FullHttpResponse response = jsonpRequest(sessionUrl + "/jsonp?c=%63allback", echoService);
        assertThat(response.getStatus(), is(HttpResponseStatus.OK));
        assertThat(response.content().toString(UTF_8), equalTo("callback(\"o\");\r\n"));
        assertThat(response.headers().get(CONTENT_TYPE), equalTo(Transports.CONTENT_TYPE_JAVASCRIPT));
        verifyNotCached(response);

        final String data = "d=%5B%22x%22%5D";
        final FullHttpResponse sendResponse = jsonpSend(sessionUrl + "/jsonp_send", data, echoService);
        assertThat(sendResponse.getStatus(), is(HttpResponseStatus.OK));
        assertThat(sendResponse.content().toString(UTF_8), equalTo("ok"));
        assertThat(sendResponse.headers().get(CONTENT_TYPE), equalTo(Transports.CONTENT_TYPE_PLAIN));
        verifyNotCached(response);

        final FullHttpResponse pollResponse = jsonpRequest(sessionUrl + "/jsonp?c=callback", echoService);
        assertThat(pollResponse.getStatus(), is(HttpResponseStatus.OK));
        assertThat(pollResponse.headers().get(CONTENT_TYPE), equalTo(Transports.CONTENT_TYPE_JAVASCRIPT));
        assertThat(pollResponse.content().toString(UTF_8), equalTo("callback(\"a[\\\"x\\\"]\");\r\n"));
        verifyNotCached(pollResponse);
    }
View Full Code Here

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

     * Equivalent to JsonPolling.test_no_callback in sockjs-protocol-0.3.3.py.
     */
    @Test
    public void jsonpPollingTestNoCallback() throws Exception {
        final SockJsServiceFactory echoService = echoService();
        final FullHttpResponse response = jsonpRequest("/echo/a/a/jsonp", echoService);
        assertThat(response.getStatus(), is(HttpResponseStatus.INTERNAL_SERVER_ERROR));
        assertThat(response.content().toString(UTF_8), equalTo("\"callback\" parameter required"));
    }
View Full Code Here

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

    public void jsonpPollingTestInvalidJson() throws Exception {
        final String serviceName = "/echo";
        final String sessionUrl = serviceName + "/222/" + UUID.randomUUID().toString();
        final SockJsServiceFactory echoService = echoService();

        final FullHttpResponse response = jsonpRequest(sessionUrl + "/jsonp?c=x", echoService);
        assertThat(response.getStatus(), is(HttpResponseStatus.OK));
        assertThat(response.content().toString(UTF_8), equalTo("x(\"o\");\r\n"));

        assertBrokenJSONEncoding(jsonpSend(sessionUrl + "/jsonp_send", "d=%5B%22x", echoService));
        assertPayloadExpected(jsonpSend(sessionUrl + "/jsonp_send", "", echoService));
        assertPayloadExpected(jsonpSend(sessionUrl + "/jsonp_send", "d=", echoService));
        assertPayloadExpected(jsonpSend(sessionUrl + "/jsonp_send", "p=p", echoService));

        final FullHttpResponse sendResponse = jsonpSend(sessionUrl + "/jsonp_send", "d=%5B%22b%22%5D", echoService);
        assertThat(sendResponse.getStatus(), is(HttpResponseStatus.OK));

        final FullHttpResponse pollResponse = jsonpRequest(sessionUrl + "/jsonp?c=x", echoService);
        assertThat(pollResponse.getStatus(), is(HttpResponseStatus.OK));
        assertThat(pollResponse.content().toString(UTF_8), equalTo("x(\"a[\\\"b\\\"]\");\r\n"));
    }
View Full Code Here

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

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

        final String data = "d=%5B%22abc%22%5D";
        final FullHttpResponse sendResponse = jsonpSend(sessionUrl + "/jsonp_send", data, echoService);
        assertThat(sendResponse.getStatus(), is(HttpResponseStatus.OK));

        final FullHttpRequest plainRequest = httpRequest(sessionUrl + "/jsonp_send", POST);
        plainRequest.headers().set(CONTENT_TYPE, "text/plain");
        final ByteBuf byteBuf = Unpooled.copiedBuffer("[\"%61bc\"]", UTF_8);
        plainRequest.content().writeBytes(byteBuf);
        byteBuf.release();
        final FullHttpResponse plainResponse = jsonpSend(plainRequest, echoService);
        assertThat(plainResponse.getStatus(), is(HttpResponseStatus.OK));

        final FullHttpResponse pollResponse = jsonpRequest(sessionUrl + "/jsonp?c=x", echoService);
        assertThat(pollResponse.getStatus(), is(HttpResponseStatus.OK));
        assertThat(pollResponse.content().toString(UTF_8), equalTo("x(\"a[\\\"abc\\\",\\\"%61bc\\\"]\");\r\n"));
    }
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.