public void handle(RoutingContext rc) { if (log.isTraceEnabled()) log.trace("In Info handler"); rc.response().putHeader("Content-Type", "application/json; charset=UTF-8"); setNoCacheHeaders(rc); JsonObject json = new JsonObject(); json.put("websocket", websocket); json.put("cookie_needed", options.isInsertJSESSIONID()); json.put("origins", new JsonArray().add("*:*")); // Java ints are signed, so we need to use a long and add the offset so // the result is not negative json.put("entropy", RAND_OFFSET + new Random().nextInt()); setCORS(rc); rc.response().end(json.encode()); } };
static void setJSESSIONID(SockJSHandlerOptions options, RoutingContext rc) { String cookies = rc.request().getHeader("cookie"); if (options.isInsertJSESSIONID()) { //Preserve existing JSESSIONID, if any if (cookies != null) { String[] parts; if (cookies.contains(";")) { parts = cookies.split(";"); } else { parts = new String[] {cookies}; } for (String part: parts) { if (part.startsWith("JSESSIONID")) { cookies = part + "; path=/"; break; } } } if (cookies == null) { cookies = "JSESSIONID=dummy; path=/"; } rc.response().putHeader("Set-Cookie", cookies); } }
public void handle(RoutingContext rc) { if (log.isTraceEnabled()) log.trace("In Info handler"); rc.response().putHeader("Content-Type", "application/json; charset=UTF-8"); setNoCacheHeaders(rc); JsonObject json = new JsonObject(); json.put("websocket", websocket); json.put("cookie_needed", options.isInsertJSESSIONID()); json.put("origins", new JsonArray().add("*:*")); // Java ints are signed, so we need to use a long and add the offset so // the result is not negative json.put("entropy", RAND_OFFSET + new Random().nextInt()); setCORS(rc); rc.response().end(json.encode()); } };
static void setJSESSIONID(SockJSHandlerOptions options, RoutingContext rc) { String cookies = rc.request().getHeader("cookie"); if (options.isInsertJSESSIONID()) { //Preserve existing JSESSIONID, if any if (cookies != null) { String[] parts; if (cookies.contains(";")) { parts = cookies.split(";"); } else { parts = new String[] {cookies}; } for (String part: parts) { if (part.startsWith("JSESSIONID")) { cookies = part + "; path=/"; break; } } } if (cookies == null) { cookies = "JSESSIONID=dummy; path=/"; } rc.response().putHeader("Set-Cookie", cookies); } }