private static boolean isLegacyClient(HttpAcceptSession httpSession) { // detect old clients boolean hasOld3xClientVersionParam = "10.05".equals(httpSession.getParameter(".kv")); boolean hasOld3xBalancerRequestParameter = httpSession.getParameter(".kl") != null; // detect old connectors boolean hasNextProtocolDefined = (null != httpSession.getReadHeader("X-Next-Protocol") || null != httpSession.getParameter(".knp")); return hasOld3xClientVersionParam || hasOld3xBalancerRequestParameter || !hasNextProtocolDefined; }
private static boolean isExplicitAccessControl(HttpAcceptSession httpSession) { return "ex".equals(httpSession.getParameter(".kac")); }
@Override public void writeFile(HttpAcceptSession httpSession) { String sOriginId = httpSession.getParameter("soid"); String authority = httpSession.getParameter("authority"); String call = "(function() { var element = document.getElementById(\"" + sOriginId + "\");" + "if (element) { " +" element.Packages.org.kaazing.gateway.client.html5.impl.BridgeUtil.bridgeJsCall(\"" + authority +"\");}})();"; IoBuffer buf = IoBuffer.wrap(call.getBytes()); httpSession.write(buf); } }
protected Encoding getWebSocketEncoding(HttpAcceptSession session) { String encoding = session.getParameter("encoding"); Encoding wsEncoding = Encoding.TEXT; // default to TEXT if (encoding == null) { String wsVersion = session.getReadHeader(HEADER_WEBSOCKET_VERSION); if ("13".equals(wsVersion)) { wsEncoding = Encoding.BINARY; } String acceptFrameType = session.getReadHeader("X-Accept-FrameType"); if ("binary".equals(acceptFrameType)) { wsEncoding = Encoding.BINARY; } else if ("base64".equals(acceptFrameType)) { wsEncoding = Encoding.BASE64; } else if ("utf8".equals(acceptFrameType)) { wsEncoding = Encoding.UTF8; } } else if ("binary".equals(encoding)) { wsEncoding = Encoding.BINARY; } else if ("base64".equals(encoding)) { wsEncoding = Encoding.BASE64; } else if ("utf8".equals(encoding)) { wsEncoding = Encoding.UTF8; } return wsEncoding; }
protected URI getWebSocketLocation(HttpAcceptSession session, WebSocketWireProtocol wireProtocol) throws URISyntaxException { URI uri = session.getRequestURL(); String scheme = session.isSecure() ? "wss" : "ws"; // Note: According to specification, WebSocket location MUST CONTAIN // query string and fragment "resource name" as defined by the // middle token of the first line of the WebSocket handshake // Note: Chrome 4.0.249.78 closes WebSocket after specification-compliant // handshake if WebSocket location contains a query string. // Workaround to avoid echoing back the query string in that case. String query = uri.getQuery(); if ("nq".equals(session.getParameter(".kl"))) { query = null; } int port = uri.getPort(); if (wireProtocol == WebSocketWireProtocol.HIXIE_76) { if (session.isSecure() && port == 443) { port = -1; } else if (!session.isSecure() && port == 80) { port = -1; } } URI location = new URI(scheme, uri.getUserInfo(), uri.getHost(), port, uri.getPath(), query, uri .getFragment()); return location; }
if (!"s".equals(session.getParameter(".kd"))) { String contentTypeOverride = session.getParameter(".kc"); if (contentTypeOverride != null) { if (contentTypeOverride.indexOf(';') == -1) { if(session.getParameter(".kns") != null) { String cacheControlOverride = session.getParameter(".kcc"); if (isClientIE11 && cacheControlOverride == null) { cacheControlOverride = "private"; //KG-10590 add .kcc=private for IE11 client String clientBuffer = session.getParameter(".kb"); if (clientBuffer != null) { String clientPadding = session.getParameter(".kp"); if (isClientIE11 && clientPadding == null) { clientPadding = "2048"; //KG-10590 add .kp=2048 for IE11 client String clientBlockPadding = session.getParameter(".kbp"); if (clientBlockPadding != null) { int paddingSize = Integer.parseInt(clientBlockPadding);
String flushDelay = session.getParameter(".kf"); if (isClientIE11 && flushDelay == null) { flushDelay = "200"; //KG-10590 add .kf=200 for IE11 client
@Override protected void doSessionOpened(HttpAcceptSession session) throws Exception { HttpMethod method = session.getMethod(); String service = session.getParameter("service");
if (!useHttpStreaming && !"s".equals(httpSession.getParameter(".kd"))) { String contentTypeOverride = httpSession.getParameter(".kc"); if (contentTypeOverride != null) { if (contentTypeOverride.indexOf(';') == -1) { String cacheControlOverride = httpSession.getParameter(".kcc"); if (cacheControlOverride != null) { cacheControl = cacheControlOverride; String clientBuffer = httpSession.getParameter(".kb"); if (clientBuffer != null) { String clientPadding = httpSession.getParameter(".kp"); if (clientPadding != null) { int paddingSize = Integer.parseInt(clientPadding); String clientBlockPadding = httpSession.getParameter(".kbp"); if (clientBlockPadding != null) { int paddingSize = Integer.parseInt(clientBlockPadding); httpSession.write(sseMessage); final String flushDelay = httpSession.getParameter(".kf"); if (flushDelay != null) {
@Override protected void doSessionOpened(HttpAcceptSession session) throws Exception { HttpMethod method = session.getMethod(); String service = session.getParameter("service");
String requestedKeepAliveIntervalInSeconds = session.getParameter(".kkt"); if (requestedKeepAliveIntervalInSeconds != null) { clientIdleTimeout = Integer.parseInt(requestedKeepAliveIntervalInSeconds);
!"Y".equals(session.getParameter(".kl"))) { assert balancerKeys instanceof List; List<String> availableBalanceeURIs = (List<String>) balancerKeys;