Package io.netty.handler.codec.http

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


    private void setCookies(HttpResponse httpResponse, HttpServletResponse httpServletResponse) {
        if (httpResponse.getCookies() != null) {
            for (Cookie cookie : httpResponse.getCookies()) {
                for (String value : cookie.getValues()) {
                    httpServletResponse.addHeader(SET_COOKIE, ServerCookieEncoder.encode(new DefaultCookie(cookie.getName(), value)));
                }
            }
        }
    }
View Full Code Here


        // headers.set("Connection","keep-alive");
        // headers.set("Keep-Alive","300");

        headers.set(
                HttpHeaders.Names.COOKIE, ClientCookieEncoder.encode(
                        new DefaultCookie("my-cookie", "foo"),
                        new DefaultCookie("another-cookie", "bar"))
        );

        // send request
        List<Entry<String, String>> entries = headers.entries();
        channel.writeAndFlush(request);
View Full Code Here

            }
        }
    }

    public YokeCookie(@NotNull final String name, final Mac mac) {
        this(new DefaultCookie(name, ""), mac);
    }
View Full Code Here

    public YokeCookie(@NotNull final String name, final Mac mac) {
        this(new DefaultCookie(name, ""), mac);
    }

    public YokeCookie(@NotNull final String name, @NotNull final String value) {
        this(new DefaultCookie(name, value), null);
    }
View Full Code Here

        headers.set(HttpHeaders.Names.ACCEPT_LANGUAGE, "fr");
        headers.set(HttpHeaders.Names.REFERER, uriSimple.toString());
        headers.set(HttpHeaders.Names.USER_AGENT, "Netty Simple Http Client side");
        headers.set(HttpHeaders.Names.ACCEPT, "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");

        headers.set(HttpHeaders.Names.COOKIE, ClientCookieEncoder.encode(new DefaultCookie("my-cookie", "foo"),
                new DefaultCookie("another-cookie", "bar")));

        // send request
        List<Entry<String, String>> entries = headers.entries();
        channel.write(request).sync();

View Full Code Here

            // Set some example cookies.
            request.headers().set(
                    HttpHeaders.Names.COOKIE,
                    ClientCookieEncoder.encode(
                            new DefaultCookie("my-cookie", "foo"),
                            new DefaultCookie("another-cookie", "bar")));

            // Send the HTTP request.
            ch.write(request);

            // Wait for the server to close the connection.
View Full Code Here

        DefaultHttpRequest nettyRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "");
        String cookie1Name = "PREF";
        String cookie1Value = "ID=a95756377b78e75e:FF=0:TM=1392709628:LM=1392709628:S=a5mOVvTB7DBkexgi";
        String cookie1Domain = ".google.com";
        String cookie1Path = "/";
        Cookie cookie = new DefaultCookie(cookie1Name, cookie1Value);
        cookie.setPath(cookie1Path);
        cookie.setDomain(cookie1Domain);
        new HttpClientRequest<ByteBuf>(nettyRequest).withCookie(cookie);
        String cookieHeader = nettyRequest.headers().get(HttpHeaders.Names.COOKIE);
        Assert.assertNotNull("No cookie header found.", cookieHeader);
        Set<Cookie> decodeCookies = CookieDecoder.decode(cookieHeader);
        Assert.assertNotNull("No cookie found with name.", decodeCookies);
View Full Code Here

        HttpServerResponse<ByteBuf> response =
                new HttpServerResponse<ByteBuf>(new NoOpChannelHandlerContext().channel(), nettyResponse,
                                                new MetricEventsSubject<HttpServerMetricsEvent<?>>());
        String cookieName = "name";
        String cookieValue = "value";
        response.addCookie(new DefaultCookie(cookieName, cookieValue));
        String cookieHeader = nettyResponse.headers().get(HttpHeaders.Names.SET_COOKIE);
        Assert.assertNotNull("Cookie header not found.", cookieHeader);
        Set<Cookie> decode = CookieDecoder.decode(cookieHeader);
        Assert.assertNotNull("Decoded cookie not found.", decode);
        Assert.assertEquals("Unexpected number of decoded cookie not found.", 1, decode.size());
View Full Code Here

        // headers.set("Connection","keep-alive");
        // headers.set("Keep-Alive","300");

        headers.set(
                HttpHeaders.Names.COOKIE, ClientCookieEncoder.encode(
                        new DefaultCookie("my-cookie", "foo"),
                        new DefaultCookie("another-cookie", "bar"))
        );

        // send request
        List<Entry<String, String>> entries = headers.entries();
        channel.writeAndFlush(request);
View Full Code Here

        //connection will not close but needed
        // headers.set("Connection","keep-alive");

        headers.set(
                HttpHeaders.Names.COOKIE, ClientCookieEncoder.encode(
                        new DefaultCookie("my-cookie", "foo"),
                        new DefaultCookie("another-cookie", "bar"))
        );

        // send request
        List<Entry<String, String>> entries = headers.entries();
        channel.writeAndFlush(request);
View Full Code Here

TOP

Related Classes of io.netty.handler.codec.http.DefaultCookie

Copyright © 2018 www.massapicom. 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.