A second round of fixes to simplify the web application setup code and provide for a connection context accessible by the application when handling web requests.

This commit is contained in:
wcrisman
2014-07-11 12:32:03 -07:00
parent 07b8c2ff8d
commit 2b035e092c
13 changed files with 381 additions and 374 deletions

View File

@@ -2974,11 +2974,16 @@ private boolean processClientRequest(SocketContext context, final Request reques
request.setSession(session = application.createSession());
clientHadBadSession = request.getSessionId() != null;
hasNewSessionData = true;
//Basic error checking.//
if(session == null) {
throw new RuntimeException("WebApplication failure: Cannot return a null value from IWebApplication.createSession()");
}//if//
}//if//
//If we are handling a secure connection then setup or locate the secure session object.//
if(context.sslEngine != null) {
if((request.getSecureSessionId() != null) && (session != null) && (session.getSecureSessionId() != null)) {
if((request.getSecureSessionId() != null) && (session.getSecureSessionId() != null)) {
if(session.getSecureSessionId().equals(request.getSecureSessionId())) {
allowSecureAccess = true;
}//if//
@@ -2986,7 +2991,7 @@ private boolean processClientRequest(SocketContext context, final Request reques
Debug.log(new RuntimeException("Error: The client did not send the correct secure session id with the request!"));
}//else//
}//if//
else if(session != null && session.getSecureSessionId() == null) {
else if(session.getSecureSessionId() == null) {
//TODO: Remove
if(debug) {
Debug.log("SC: " + context.id + " Creating Secure Session");
@@ -3004,7 +3009,7 @@ private boolean processClientRequest(SocketContext context, final Request reques
//Save the session immediately since the requested resource might not indicate to the application that the session was updated.//
//Note: We shouldn't have any problems with multiple threads from the same client each creating their own session data since every browser should start with a single thread requesting a single resource before multiple threads are used to download all the child resources.//
if(hasNewSessionData && session != null) {
if(hasNewSessionData) {
//Store the session store in the db.//
session.updateRepository();
}//if//
@@ -3068,7 +3073,7 @@ private boolean processClientRequest(SocketContext context, final Request reques
* Processes a client request.
* @param request The request.
* @param response The response container.
* @param session The session for the request. This may be null if the application does not use a session object.
* @param session The session for the request. This will never be null, even if the application does not use session data (or provide a SessionData instance).
* @param allowSecureAccess Whether the session's secure sessions should be accessable.
* @param clientHadBadSession Whether the client's request contained a session reference that could not be found on the server.
* @return Whether request is in a receive state. Will be false if the request generated a response that could not be completely transmitted.