Package io.netty.handler.codec.http

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


    @Test
    public void webSocketHybi10Firefox602ConnectionHeader() throws Exception {
        final SockJsServiceFactory echoFactory = echoService();
        final EmbeddedChannel ch = ChannelUtil.webSocketChannel(echoFactory.config());
        final FullHttpRequest request = HttpUtil.webSocketUpgradeRequest("/websocket", WebSocketVersion.V08);
        request.headers().set(CONNECTION, "keep-alive, Upgrade");
        ch.writeInbound(request);
        final HttpResponse response = HttpUtil.decode(ch);
        assertThat(response.getStatus(), is(HttpResponseStatus.SWITCHING_PROTOCOLS));
        assertThat(response.headers().get(CONNECTION), equalTo("Upgrade"));
    }
View Full Code Here


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

        final FullHttpRequest okRequest = httpRequest(sessionUrl + "/xhr", POST);
        okRequest.headers().set(ACCESS_CONTROL_REQUEST_HEADERS, "a, b, c");
        final HttpResponse response = xhrRequest(okRequest, echoFactory);
        assertThat(response.getStatus(), is(HttpResponseStatus.OK));
        SockJsTestUtil.assertCORSHeaders(response, "*");
        assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_HEADERS), equalTo("a, b, c"));

View Full Code Here

        SockJsTestUtil.assertCORSHeaders(response, "*");
        assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_HEADERS), equalTo("a, b, c"));

        final String emptySessionUrl = echoFactory.config().prefix() + "/abc/" + UUID.randomUUID().toString();
        final FullHttpRequest emptyHeaderRequest = httpRequest(emptySessionUrl + "/xhr", POST);
        emptyHeaderRequest.headers().set(ACCESS_CONTROL_REQUEST_HEADERS, "");
        final HttpResponse emptyHeaderResponse = xhrRequest(emptyHeaderRequest, echoFactory);
        assertThat(emptyHeaderResponse.getStatus(), is(HttpResponseStatus.OK));
        SockJsTestUtil.assertCORSHeaders(response, "*");
        assertThat(emptyHeaderResponse.headers().get(ACCESS_CONTROL_ALLOW_HEADERS), is(nullValue()));

View Full Code Here

        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));
View Full Code Here

        final SockJsConfig config = SockJsConfig.withPrefix(serviceName).cookiesNeeded().build();
        final EmbeddedChannel ch = channelForService(echoService(config));
        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

    public void http10TestSynchronous() throws Exception {
        final SockJsServiceFactory echoFactory = echoService();

        final EmbeddedChannel ch = channelForService(echoFactory);
        final FullHttpRequest request = httpGetRequest(echoFactory.config().prefix(), HTTP_1_0);
        request.headers().set(CONNECTION, KEEP_ALIVE);
        ch.writeInbound(request);
        final FullHttpResponse response = ch.readOutbound();
        assertThat(response.getStatus(), is(HttpResponseStatus.OK));
        assertThat(response.getProtocolVersion(), is(HTTP_1_0));
        assertThat(response.headers().get(TRANSFER_ENCODING), is(nullValue()));
View Full Code Here

        final SockJsServiceFactory closeFactory = closeService();
        final String sessionUrl = closeFactory.config().prefix() + "/222/" + UUID.randomUUID().toString();
        final EmbeddedChannel ch = channelForService(closeFactory);
        removeLastInboundMessageHandlers(ch);
        final FullHttpRequest request = httpPostRequest(sessionUrl + Transports.Type.XHR_STREAMING.path(), HTTP_1_0);
        request.headers().set(CONNECTION, KEEP_ALIVE);
        ch.writeInbound(request);

        final HttpResponse response =  ch.readOutbound();
        assertThat(response.getStatus(), equalTo(HttpResponseStatus.OK));
        assertThat(response.getProtocolVersion(), is(HTTP_1_0));
View Full Code Here

    public void http11TestSynchronous() throws Exception {
        final SockJsServiceFactory echoFactory = echoService();

        final EmbeddedChannel ch = channelForService(echoFactory);
        final FullHttpRequest request = httpGetRequest(echoFactory.config().prefix(), HTTP_1_1);
        request.headers().set(CONNECTION, KEEP_ALIVE);
        ch.writeInbound(request);

        final FullHttpResponse response = ch.readOutbound();
        assertThat(response.getStatus(), is(HttpResponseStatus.OK));
        assertThat(response.getProtocolVersion(), is(HTTP_1_1));
View Full Code Here

        final SockJsServiceFactory closeFactory = closeService();
        final String sessionUrl = closeFactory.config().prefix() + "/222/" + UUID.randomUUID().toString();
        final EmbeddedChannel ch = channelForService(closeFactory);
        removeLastInboundMessageHandlers(ch);
        final FullHttpRequest request = httpPostRequest(sessionUrl + Transports.Type.XHR_STREAMING.path(), HTTP_1_1);
        request.headers().set(CONNECTION, KEEP_ALIVE);
        ch.writeInbound(request);

        final HttpResponse response =  ch.readOutbound();
        assertThat(response.getStatus(), equalTo(HttpResponseStatus.OK));
        assertThat(response.getProtocolVersion(), is(HTTP_1_1));
View Full Code Here

        assertThat(response.headers().get(CONTENT_LENGTH), is(nullValue()));
    }

    private static FullHttpRequest webSocketUpgradeRequest(final String path, final WebSocketVersion version) {
        final FullHttpRequest req = new DefaultFullHttpRequest(HTTP_1_1, GET, path);
        req.headers().set(HOST, "server.test.com");
        req.headers().set(UPGRADE, WEBSOCKET.toString());
        req.headers().set(CONNECTION, "Upgrade");

        if (version == WebSocketVersion.V00) {
            req.headers().set(CONNECTION, "Upgrade");
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.