Package io.netty.handler.codec.http

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


    public void messageReceivedNoFormDataParameter() {
        final FullHttpResponse response = processHttpRequest(requestWithFormData(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."));
        response.release();
    }

    @Test
    public void messageReceivedFormDataParameter() {
        final String data = "[\"some message\"]";
View Full Code Here


        final FullHttpResponse response = processHttpRequest(requestWithFormData(data));
        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);
        response.release();
    }

    @Test
    public void messageReceivedInvalidJson() {
        final String data = "[\"some message";
View Full Code Here

        final FullHttpResponse response = processHttpRequest(requestWithFormData(data));
        assertThat(response.getStatus(), equalTo(HttpResponseStatus.INTERNAL_SERVER_ERROR));
        assertThat(response.getProtocolVersion(), equalTo(HttpVersion.HTTP_1_1));
        SockJsTestUtil.verifyContentType(response, Transports.CONTENT_TYPE_PLAIN);
        assertThat(response.content().toString(UTF_8), equalTo("Broken JSON encoding."));
        response.release();
    }

    private static FullHttpResponse processHttpRequest(final FullHttpRequest request) {
        final XhrSendTransport transport = new XhrSendTransport(SockJsConfig.withPrefix("/test")
                .cookiesNeeded().build());
View Full Code Here

    public void iframeHtm() throws Exception {
        final SockJsConfig config = config();
        final String path = config.prefix() + "/iframe.htm";
        final FullHttpResponse response = Iframe.response(config, createHttpRequest(path));
        assertThat(response.getStatus().code(), is(HttpResponseStatus.NOT_FOUND.code()));
        response.release();
    }

    @Test
    public void iframeHTML() throws Exception {
        final SockJsConfig config = config();
View Full Code Here

    public void iframeHTML() throws Exception {
        final SockJsConfig config = config();
        final String path = config.prefix() + "/iframe.HTML";
        final FullHttpResponse response = Iframe.response(config, createHttpRequest(path));
        assertThat(response.getStatus().code(), is(HttpResponseStatus.NOT_FOUND.code()));
        response.release();
    }

    @Test
    public void iframeHtmlUppercase() throws Exception {
        final SockJsConfig config = config();
View Full Code Here

    public void iframeHtmlUppercase() throws Exception {
        final SockJsConfig config = config();
        final String path = config.prefix() + "/IFRAME.HTML";
        final FullHttpResponse response = Iframe.response(config, createHttpRequest(path));
        assertThat(response.getStatus().code(), is(HttpResponseStatus.NOT_FOUND.code()));
        response.release();
    }

    @Test
    public void iframeXml() throws Exception {
        final SockJsConfig config = config();
View Full Code Here

    public void iframeXml() throws Exception {
        final SockJsConfig config = config();
        final String path = config.prefix() + "/iframe.xml";
        final FullHttpResponse response = Iframe.response(config, createHttpRequest(path));
        assertThat(response.getStatus().code(), is(HttpResponseStatus.NOT_FOUND.code()));
        response.release();
    }

    @Test
    public void iframeUppercase() throws Exception {
        final SockJsConfig config = config();
View Full Code Here

    public void iframeUppercase() throws Exception {
        final SockJsConfig config = config();
        final String path = config.prefix() + "/IFRAME";
        final FullHttpResponse response = Iframe.response(config, createHttpRequest(path));
        assertThat(response.getStatus().code(), is(HttpResponseStatus.NOT_FOUND.code()));
        response.release();
    }

    @Test
    public void ifNoneMatchHeader() throws Exception {
        final SockJsConfig config = config();
View Full Code Here

        final HttpRequest httpRequest = createHttpRequest(path);
        httpRequest.headers().set(HttpHeaders.Names.IF_NONE_MATCH, "*");
        final FullHttpResponse response = Iframe.response(config, httpRequest);
        assertThat(response.headers().get(HttpHeaders.Names.SET_COOKIE), equalTo("JSESSIONID=dummy; path=/"));
        assertThat(response.getStatus().code(), is(HttpResponseStatus.NOT_MODIFIED.code()));
        response.release();
    }

    @Test
    public void iframeHtml() throws Exception {
        final SockJsConfig config = config();
View Full Code Here

        assertThat(response.headers().get(HttpHeaders.Names.CONTENT_TYPE), equalTo("text/html; charset=UTF-8"));
        assertThat(response.headers().get(HttpHeaders.Names.CACHE_CONTROL), equalTo("max-age=31536000, public"));
        assertThat(response.headers().get(HttpHeaders.Names.EXPIRES), is(notNullValue()));
        assertThat(response.headers().get(HttpHeaders.Names.SET_COOKIE), is(nullValue()));
        assertThat(response.headers().get(HttpHeaders.Names.ETAG), is(notNullValue()));
        response.release();
    }

    private static SockJsConfig config() {
        return SockJsConfig.withPrefix("/simplepush").sockJsUrl("http://cdn.sockjs.org/sockjs-0.3.4.min.js").build();
    }
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.