Package io.netty.handler.codec.http

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


            buf.append("VERSION: ").append(request.protocolVersion()).append("\r\n");
            buf.append("HOSTNAME: ").append(request.headers().get(HOST, "unknown")).append("\r\n");
            buf.append("REQUEST_URI: ").append(request.uri()).append("\r\n\r\n");

            HttpHeaders headers = request.headers();
            if (!headers.isEmpty()) {
                for (Map.Entry<String, String> h: headers) {
                    String key = h.getKey();
                    String value = h.getValue();
                    buf.append("HEADER: ").append(key).append(" = ").append(value).append("\r\n");
View Full Code Here


    @Override
    public void write(final ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
        if (msg instanceof HttpRequest && WebSocketExtensionUtil.isWebsocketUpgrade((HttpRequest) msg)) {
            HttpRequest request = (HttpRequest) msg;
            String headerValue = request.headers().get(HttpHeaders.Names.SEC_WEBSOCKET_EXTENSIONS);

            for (WebSocketClientExtensionHandshaker extentionHandshaker : extensionHandshakers) {
                WebSocketExtensionData extensionData = extentionHandshaker.newRequestData();
                headerValue = WebSocketExtensionUtil.appendExtension(headerValue,
                        extensionData.name(), extensionData.parameters());
View Full Code Here

                WebSocketExtensionData extensionData = extentionHandshaker.newRequestData();
                headerValue = WebSocketExtensionUtil.appendExtension(headerValue,
                        extensionData.name(), extensionData.parameters());
            }

            request.headers().set(HttpHeaders.Names.SEC_WEBSOCKET_EXTENSIONS, headerValue);
        }

        super.write(ctx, msg, promise);
    }
View Full Code Here

            throws Exception {
        if (msg instanceof HttpRequest) {
            HttpRequest request = (HttpRequest) msg;

            if (WebSocketExtensionUtil.isWebsocketUpgrade(request)) {
                String extensionsHeader = request.headers().get(HttpHeaders.Names.SEC_WEBSOCKET_EXTENSIONS);

                if (extensionsHeader != null) {
                    List<WebSocketExtensionData> extensions =
                            WebSocketExtensionUtil.extractExtensions(extensionsHeader);
                    int rsv = 0;
View Full Code Here

               {
                  //get this first incase it removes itself
                  HttpUpgradeHandler httpUpgradeHandler = (HttpUpgradeHandler) ch.pipeline().get("http-upgrade");
                  URI uri = new URI("http", null, host, port, null, null, null);
                  HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri.getRawPath());
                  request.headers().set(HttpHeaders.Names.HOST, host);
                  request.headers().set(HttpHeaders.Names.UPGRADE, HORNETQ_REMOTING);
                  request.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.UPGRADE);

                  // Get 16 bit nonce and base 64 encode it
                  byte[] nonce = randomBytes(16);
View Full Code Here

                  //get this first incase it removes itself
                  HttpUpgradeHandler httpUpgradeHandler = (HttpUpgradeHandler) ch.pipeline().get("http-upgrade");
                  URI uri = new URI("http", null, host, port, null, null, null);
                  HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri.getRawPath());
                  request.headers().set(HttpHeaders.Names.HOST, host);
                  request.headers().set(HttpHeaders.Names.UPGRADE, HORNETQ_REMOTING);
                  request.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.UPGRADE);

                  // Get 16 bit nonce and base 64 encode it
                  byte[] nonce = randomBytes(16);
                  String key = base64(nonce);
View Full Code Here

                  HttpUpgradeHandler httpUpgradeHandler = (HttpUpgradeHandler) ch.pipeline().get("http-upgrade");
                  URI uri = new URI("http", null, host, port, null, null, null);
                  HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri.getRawPath());
                  request.headers().set(HttpHeaders.Names.HOST, host);
                  request.headers().set(HttpHeaders.Names.UPGRADE, HORNETQ_REMOTING);
                  request.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.UPGRADE);

                  // Get 16 bit nonce and base 64 encode it
                  byte[] nonce = randomBytes(16);
                  String key = base64(nonce);
                  request.headers().set(SEC_HORNETQ_REMOTING_KEY, key);
View Full Code Here

                  request.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.UPGRADE);

                  // Get 16 bit nonce and base 64 encode it
                  byte[] nonce = randomBytes(16);
                  String key = base64(nonce);
                  request.headers().set(SEC_HORNETQ_REMOTING_KEY, key);
                  ch.attr(REMOTING_KEY).set(key);

                  HornetQClientLogger.LOGGER.debugf("Sending HTTP request %s", request);

                  // Send the HTTP request.
View Full Code Here

        if (HttpHeaders.is100ContinueExpected(request)) {
          ch.writeAndFlush(new DefaultFullHttpResponse(HTTP_1_1, CONTINUE));
        }

        if (wsHandlerManager.hasHandlers() && request.headers().contains(io.vertx.core.http.HttpHeaders.UPGRADE, io.vertx.core.http.HttpHeaders.WEBSOCKET, true)) {
          // As a fun part, Firefox 6.0.2 supports Websockets protocol '7'. But,
          // it doesn't send a normal 'Connection: Upgrade' header. Instead it
          // sends: 'Connection: keep-alive, Upgrade'. Brilliant.
          String connectionHeader = request.headers().get(io.vertx.core.http.HttpHeaders.CONNECTION);
          if (connectionHeader == null || !connectionHeader.toLowerCase().contains("upgrade")) {
View Full Code Here

        if (wsHandlerManager.hasHandlers() && request.headers().contains(io.vertx.core.http.HttpHeaders.UPGRADE, io.vertx.core.http.HttpHeaders.WEBSOCKET, true)) {
          // As a fun part, Firefox 6.0.2 supports Websockets protocol '7'. But,
          // it doesn't send a normal 'Connection: Upgrade' header. Instead it
          // sends: 'Connection: keep-alive, Upgrade'. Brilliant.
          String connectionHeader = request.headers().get(io.vertx.core.http.HttpHeaders.CONNECTION);
          if (connectionHeader == null || !connectionHeader.toLowerCase().contains("upgrade")) {
            sendError("\"Connection\" must be \"Upgrade\".", BAD_REQUEST, ch);
            return;
          }
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.