Package io.netty.handler.codec.http

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


    @Test
    public void shouldMapHttpServletRequestToHttpRequest() {
        // given
        DefaultFullHttpRequest nettyHttpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/requestURI?queryStringParameterNameOne=queryStringParameterValueOne_One&queryStringParameterNameOne=queryStringParameterValueOne_Two&queryStringParameterNameTwo=queryStringParameterValueTwo_One", Unpooled.wrappedBuffer("1a!@£$%^&*()_+=-".getBytes(Charsets.UTF_8)));
        nettyHttpRequest.headers().add("headerName1", "headerValue1_1");
        nettyHttpRequest.headers().add("headerName1", "headerValue1_2");
        nettyHttpRequest.headers().add("headerName2", "headerValue2");
        nettyHttpRequest.headers().add("Host", "some.random.host");
        nettyHttpRequest.headers().add("Cookie", "cookieName1=cookieValue1  ; cookieName2=cookieValue2;   ");
        nettyHttpRequest.headers().add("Cookie", "cookieName3  =cookieValue3_1; cookieName3=cookieValue3_2");

View Full Code Here


    public void shouldMapHttpServletRequestToHttpRequest() {
        // given
        DefaultFullHttpRequest nettyHttpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/requestURI?queryStringParameterNameOne=queryStringParameterValueOne_One&queryStringParameterNameOne=queryStringParameterValueOne_Two&queryStringParameterNameTwo=queryStringParameterValueTwo_One", Unpooled.wrappedBuffer("1a!@£$%^&*()_+=-".getBytes(Charsets.UTF_8)));
        nettyHttpRequest.headers().add("headerName1", "headerValue1_1");
        nettyHttpRequest.headers().add("headerName1", "headerValue1_2");
        nettyHttpRequest.headers().add("headerName2", "headerValue2");
        nettyHttpRequest.headers().add("Host", "some.random.host");
        nettyHttpRequest.headers().add("Cookie", "cookieName1=cookieValue1  ; cookieName2=cookieValue2;   ");
        nettyHttpRequest.headers().add("Cookie", "cookieName3  =cookieValue3_1; cookieName3=cookieValue3_2");

        // when
View Full Code Here

        // given
        DefaultFullHttpRequest nettyHttpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/requestURI?queryStringParameterNameOne=queryStringParameterValueOne_One&queryStringParameterNameOne=queryStringParameterValueOne_Two&queryStringParameterNameTwo=queryStringParameterValueTwo_One", Unpooled.wrappedBuffer("1a!@£$%^&*()_+=-".getBytes(Charsets.UTF_8)));
        nettyHttpRequest.headers().add("headerName1", "headerValue1_1");
        nettyHttpRequest.headers().add("headerName1", "headerValue1_2");
        nettyHttpRequest.headers().add("headerName2", "headerValue2");
        nettyHttpRequest.headers().add("Host", "some.random.host");
        nettyHttpRequest.headers().add("Cookie", "cookieName1=cookieValue1  ; cookieName2=cookieValue2;   ");
        nettyHttpRequest.headers().add("Cookie", "cookieName3  =cookieValue3_1; cookieName3=cookieValue3_2");

        // when
        HttpRequest httpRequest = new NettyToMockServerRequestMapper().mapNettyRequestToMockServerRequest(nettyHttpRequest, false);
View Full Code Here

        DefaultFullHttpRequest nettyHttpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/requestURI?queryStringParameterNameOne=queryStringParameterValueOne_One&queryStringParameterNameOne=queryStringParameterValueOne_Two&queryStringParameterNameTwo=queryStringParameterValueTwo_One", Unpooled.wrappedBuffer("1a!@£$%^&*()_+=-".getBytes(Charsets.UTF_8)));
        nettyHttpRequest.headers().add("headerName1", "headerValue1_1");
        nettyHttpRequest.headers().add("headerName1", "headerValue1_2");
        nettyHttpRequest.headers().add("headerName2", "headerValue2");
        nettyHttpRequest.headers().add("Host", "some.random.host");
        nettyHttpRequest.headers().add("Cookie", "cookieName1=cookieValue1  ; cookieName2=cookieValue2;   ");
        nettyHttpRequest.headers().add("Cookie", "cookieName3  =cookieValue3_1; cookieName3=cookieValue3_2");

        // when
        HttpRequest httpRequest = new NettyToMockServerRequestMapper().mapNettyRequestToMockServerRequest(nettyHttpRequest, false);

View Full Code Here

        nettyHttpRequest.headers().add("headerName1", "headerValue1_1");
        nettyHttpRequest.headers().add("headerName1", "headerValue1_2");
        nettyHttpRequest.headers().add("headerName2", "headerValue2");
        nettyHttpRequest.headers().add("Host", "some.random.host");
        nettyHttpRequest.headers().add("Cookie", "cookieName1=cookieValue1  ; cookieName2=cookieValue2;   ");
        nettyHttpRequest.headers().add("Cookie", "cookieName3  =cookieValue3_1; cookieName3=cookieValue3_2");

        // when
        HttpRequest httpRequest = new NettyToMockServerRequestMapper().mapNettyRequestToMockServerRequest(nettyHttpRequest, false);

        // then
View Full Code Here

    @Test
    public void shouldMapSecureHttpServletRequestToURL() {
        // given
        DefaultFullHttpRequest nettyHttpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/requestURI");
        nettyHttpRequest.headers().add("Host", "some.random.host");

        // when
        HttpRequest httpRequest = new NettyToMockServerRequestMapper().mapNettyRequestToMockServerRequest(nettyHttpRequest, true);

        // then
View Full Code Here

      public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
      {
         if(msg instanceof DefaultFullHttpRequest)
         {
            DefaultFullHttpRequest request = (DefaultFullHttpRequest) msg;
            HttpHeaders headers = request.headers();
            String upgrade = headers.get("upgrade");
            if(upgrade != null && upgrade.equalsIgnoreCase("websocket"))
            {
               ctx.pipeline().addLast("websocket-handler", new WebSocketServerHandler());
               ctx.pipeline().addLast(new ProtocolDecoder(false, false));
View Full Code Here

      public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
      {
         if(msg instanceof DefaultFullHttpRequest)
         {
            DefaultFullHttpRequest request = (DefaultFullHttpRequest) msg;
            HttpHeaders headers = request.headers();
            String upgrade = headers.get("upgrade");
            if(upgrade != null && upgrade.equalsIgnoreCase("websocket"))
            {
               ctx.pipeline().addLast("websocket-handler", new WebSocketServerHandler());
               ctx.pipeline().addLast(new ProtocolDecoder(false, false));
View Full Code Here

        } else {
            content = Unpooled.EMPTY_BUFFER;
        }

        FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, httpMethod, msg.path(), content);
        request.headers().set(HttpHeaders.Names.USER_AGENT, env().userAgent());
        if (msg instanceof InsertBucketRequest || msg instanceof UpdateBucketRequest) {
            request.headers().set(HttpHeaders.Names.ACCEPT, "*/*");
            request.headers().set(HttpHeaders.Names.CONTENT_TYPE, "application/x-www-form-urlencoded");
        }
        request.headers().set(HttpHeaders.Names.CONTENT_LENGTH, content.readableBytes());
View Full Code Here

        }

        FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, httpMethod, msg.path(), content);
        request.headers().set(HttpHeaders.Names.USER_AGENT, env().userAgent());
        if (msg instanceof InsertBucketRequest || msg instanceof UpdateBucketRequest) {
            request.headers().set(HttpHeaders.Names.ACCEPT, "*/*");
            request.headers().set(HttpHeaders.Names.CONTENT_TYPE, "application/x-www-form-urlencoded");
        }
        request.headers().set(HttpHeaders.Names.CONTENT_LENGTH, content.readableBytes());

        addAuth(ctx, request, msg.bucket(), msg.password());
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.