Package io.netty.handler.codec.http

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


        if (-1 != indexOfStartOfQP && uri.length() >= indexOfStartOfQP) {
            queryString = uri.substring(indexOfStartOfQP + 1);
        } else {
            queryString = "";
        }
        decoder = new QueryStringDecoder(uri);
    }
View Full Code Here


                }

                @Override
                public MultiMap params() {
                    if (params == null) {
                        QueryStringDecoder queryStringDecoder = new QueryStringDecoder(uri());
                        Map<String, List<String>> prms = queryStringDecoder.parameters();
                        params = new CaseInsensitiveMultiMap();

                        if (!prms.isEmpty()) {
                            for (Map.Entry<String, List<String>> entry : prms.entrySet()) {
                                params.add(entry.getKey(), entry.getValue());
                            }
                        }
                    }
                    return params;
                }

                @Override
                public InetSocketAddress remoteAddress() {
                    return new InetSocketAddress("127.0.0.1", 80);
                }

                @Override
                public InetSocketAddress localAddress() {
                    return new InetSocketAddress("127.0.0.1", 80);
                }

                @Override
                public X509Certificate[] peerCertificateChain() throws SSLPeerUnverifiedException {
                    return null;
                }

                @Override
                public URI absoluteURI() {
                    return uri;
                }

                @Override
                public HttpServerRequest bodyHandler(final Handler<Buffer> bodyHandler) {
                    if (bodyHandler != null) {
                        vertx.runOnContext(new Handler<Void>() {
                            @Override
                            public void handle(Void event) {
                                bodyHandler.handle(body);
                            }
                        });
                    }
                    return this;
                }

                @Override
                public HttpServerRequest dataHandler(final Handler<Buffer> handler) {
                    if (handler != null) {
                        vertx.runOnContext(new Handler<Void>() {
                            @Override
                            public void handle(Void event) {
                                handler.handle(body);
                            }
                        });
                    }
                    return this;
                }

                @Override
                public HttpServerRequest pause() {
                    throw new UnsupportedOperationException("This mock does not support pause");
                }

                @Override
                public HttpServerRequest resume() {
                    throw new UnsupportedOperationException("This mock does not support resume");
                }

                @Override
                public HttpServerRequest endHandler(final Handler<Void> endHandler) {
                    if (endHandler != null) {
                        vertx.runOnContext(new Handler<Void>() {
                            @Override
                            public void handle(Void event) {
                                endHandler.handle(null);
                            }
                        });
                    }
                    return this;
                }

                @Override
                public NetSocket netSocket() {
                    return netSocket;
                }

                @Override
                public HttpServerRequest expectMultiPart(boolean expect) {
                    // NOOP
                    return this;
                }

                @Override
                public HttpServerRequest uploadHandler(Handler<HttpServerFileUpload> uploadHandler) {
                    throw new UnsupportedOperationException("This mock does not support uploadHandler");
                }

                @Override
                public MultiMap formAttributes() {
                    if (attributes == null) {
                        attributes = new CaseInsensitiveMultiMap();
                        if (urlEncoded) {
                            QueryStringDecoder queryStringDecoder = new QueryStringDecoder(body.toString(), false);

                            Map<String, List<String>> prms = queryStringDecoder.parameters();

                            if (!prms.isEmpty()) {
                                for (Map.Entry<String, List<String>> entry : prms.entrySet()) {
                                    attributes.add(entry.getKey(), entry.getValue());
                                }
View Full Code Here

            for (Cookie cookie : cookies) {
                responseContent.append("COOKIE: " + cookie.toString() + "\r\n");
            }
            responseContent.append("\r\n\r\n");

            QueryStringDecoder decoderQuery = new QueryStringDecoder(request.getUri());
            Map<String, List<String>> uriAttributes = decoderQuery.parameters();
            for (Entry<String, List<String>> attr: uriAttributes.entrySet()) {
                for (String attrVal: attr.getValue()) {
                    responseContent.append("URI: " + attr.getKey() + '=' + attrVal + "\r\n");
                }
            }
View Full Code Here

                    buf.append("HEADER: ").append(key).append(" = ").append(value).append("\r\n");
                }
                buf.append("\r\n");
            }

            QueryStringDecoder queryStringDecoder = new QueryStringDecoder(request.getUri());
            Map<String, List<String>> params = queryStringDecoder.parameters();
            if (!params.isEmpty()) {
                for (Entry<String, List<String>> p: params.entrySet()) {
                    String key = p.getKey();
                    List<String> vals = p.getValue();
                    for (String val : vals) {
View Full Code Here

        return sendStreamingResponse(response, largeStreamContent);
    }

    public Observable<Void> simulateTimeout(HttpServerRequest<ByteBuf> httpRequest, final HttpServerResponse<ByteBuf> response) {
        String uri = httpRequest.getUri();
        QueryStringDecoder decoder = new QueryStringDecoder(uri);
        List<String> timeout = decoder.parameters().get("timeout");
        if (null != timeout && !timeout.isEmpty()) {
            // Do not use Thread.sleep() here as that blocks the eventloop and since by default the eventloop is shared,
            // a few of these timeout requests can just cause failures in other tests (if running parallely)
            return Observable.interval(Integer.parseInt(timeout.get(0)), TimeUnit.MILLISECONDS)
                             .flatMap(new Func1<Long, Observable<Void>>() {
View Full Code Here

            for (Map.Entry<String, String> h: request.getHeaders()) {
                buf.append("HEADER: " + h.getKey() + " = " + h.getValue() + "\r\n");
            }
            buf.append("\r\n");

            QueryStringDecoder queryStringDecoder = new QueryStringDecoder(request.getUri());
            Map<String, List<String>> params = queryStringDecoder.getParameters();
            if (!params.isEmpty()) {
                for (Entry<String, List<String>> p: params.entrySet()) {
                    String key = p.getKey();
                    List<String> vals = p.getValue();
                    for (String val : vals) {
View Full Code Here

            for (Cookie cookie: cookies) {
                responseContent.append("COOKIE: " + cookie.toString() + "\r\n");
            }
            responseContent.append("\r\n\r\n");

            QueryStringDecoder decoderQuery = new QueryStringDecoder(request
                    .getUri());
            Map<String, List<String>> uriAttributes = decoderQuery
                    .getParameters();
            for (String key: uriAttributes.keySet()) {
                for (String valuen: uriAttributes.get(key)) {
                    responseContent.append("URI: " + key + "=" + valuen +
                            "\r\n");
View Full Code Here

                    buf.append("HEADER: ").append(key).append(" = ").append(value).append("\r\n");
                }
                buf.append("\r\n");
            }

            QueryStringDecoder queryStringDecoder = new QueryStringDecoder(request.getUri());
            Map<String, List<String>> params = queryStringDecoder.parameters();
            if (!params.isEmpty()) {
                for (Entry<String, List<String>> p: params.entrySet()) {
                    String key = p.getKey();
                    List<String> vals = p.getValue();
                    for (String val : vals) {
View Full Code Here

            for (Cookie cookie : cookies) {
                responseContent.append("COOKIE: " + cookie + "\r\n");
            }
            responseContent.append("\r\n\r\n");

            QueryStringDecoder decoderQuery = new QueryStringDecoder(request.getUri());
            Map<String, List<String>> uriAttributes = decoderQuery.parameters();
            for (Entry<String, List<String>> attr: uriAttributes.entrySet()) {
                for (String attrVal: attr.getValue()) {
                    responseContent.append("URI: " + attr.getKey() + '=' + attrVal + "\r\n");
                }
            }
View Full Code Here

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        if (msg instanceof FullHttpRequest) {
            FullHttpRequest req = (FullHttpRequest) msg;
            QueryStringDecoder queryDecoder = new QueryStringDecoder(req.getUri());

            List<String> transport = queryDecoder.parameters().get("transport");

            if (transport != null && NAME.equals(transport.get(0))) {
                List<String> sid = queryDecoder.parameters().get("sid");
                List<String> j = queryDecoder.parameters().get("j");

                String origin = req.headers().get(HttpHeaders.Names.ORIGIN);
                ctx.channel().attr(EncoderHandler.ORIGIN).set(origin);

                String userAgent = req.headers().get(HttpHeaders.Names.USER_AGENT);
View Full Code Here

TOP

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

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.