@Override public void loadObjects(ObjectRegistry<Indexed> registry) throws Throwable { // Obtain the HTTP request this.connection = (ServerHttpConnection) registry.getObject(this.serverHttpConnectionIndex); HttpRequest request = this.connection.getRequest(); // Ensure have the HTTP session Id generator if (this.httpSessionIdGenerator == null) { this.httpSessionIdGenerator = (HttpSessionIdGenerator) registry.getObject(this.httpSessionIdGeneratorIndex); } // Ensure have the HTTP session store if (this.httpSessionStore == null) { this.httpSessionStore = (HttpSessionStore) registry.getObject(this.httpSessionStoreIndex); } // Obtain the Session Id from the Session cookie HttpRequestCookie sessionIdCookie = request.getCookies().getCookie(this.sessionIdCookieName); String sessionId = (sessionIdCookie == null ? null : sessionIdCookie.getValue()); // Handle based on Session Id being available if ((sessionId == null) || (sessionId.trim().length() == 0)) { // No established session so create a new session this.generateSessionId(); } else { // Retrieve the existing session this.loadSessionId(sessionId, false); } }
@Override public void loadValues(ValueLoader valueLoader) throws HttpException { this.context.run(() -> { // Tokenise the HTTP request HttpRequest request = this.ensureTokenised(); // Load the arguments HttpArgument argument = this.arguments; while (argument != null) { valueLoader.loadValue(argument.name, argument.value, argument.location); argument = argument.next; } // Always load cookies from request for (HttpRequestCookie cookie : request.getCookies()) { valueLoader.loadValue(cookie.getName(), cookie.getValue(), HttpValueLocation.COOKIE); } // Void return return null; }); }
@Override public Object execute(ManagedFunctionContext<HttpRouteDependencies, Indexed> context) { // Obtain the server HTTP connection ServerHttpConnection connection = (ServerHttpConnection) context .getObject(HttpRouteDependencies.SERVER_HTTP_CONNECTION); // Load the escalation handler if (this.escalationHandler != null) { connection.getResponse().setEscalationHandler(this.escalationHandler); } // Determine if potentially redirect HttpRequestCookie cookie = connection.getRequest().getCookies() .getCookie(HttpRedirectFunction.REDIRECT_COOKIE_NAME); if (cookie != null) { // Redirect, so trigger flow to import previous state context.doFlow(this.handleRedirectFlowIndex, cookie, null); return null; // serviced by redirect } // No redirect, so route the request return this.router.route(connection, context); }