Fixed compile errors by transferring more of the changes to this new branch. Previous upload doesn't compile.

This commit is contained in:
wcrisman
2014-12-07 18:34:03 -08:00
parent 2adcfad863
commit ae1de97e91
6 changed files with 46 additions and 1 deletions

View File

@@ -7,13 +7,22 @@ import com.foundation.web.WebApplication.PathSubstitution;
import com.foundation.web.interfaces.IConnectionContext;
import com.foundation.web.interfaces.IRequest;
import com.foundation.web.interfaces.IResponse;
import com.foundation.web.interfaces.ISession;
public class DefaultResourceRequestHandler extends ResourceRequestHandler {
private IHashMap nameSubstitutionMap = new LiteHashMap(10);
private IHashMap pathSubstitutionMap = new LiteHashMap(10);
/**
* DefaultResourceRequestHandler constructor.
*/
public DefaultResourceRequestHandler() {
}//DefaultResourceRequestHandler()//
/* (non-Javadoc)
* @see com.foundation.web.ResourceRequestHandler#processWebSocketUpgrade(com.foundation.web.interfaces.IRequest, com.foundation.web.interfaces.IResponse, com.foundation.web.interfaces.ISession, boolean, boolean, com.foundation.web.interfaces.IConnectionContext, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
public void processWebSocketUpgrade(IRequest request, IResponse response, ISession session, boolean isSecure, boolean clientHadBadSession, IConnectionContext connectionContext, String connection, String secWebSocketKey, String secWebSocketProtocol, String secWebSocketVersion, String origin) {
response.setError(IResponse.ERROR_UPGRADE_REJECTED);
}//processWebSocketUpgrade()//
/**
* Adds a resource name subtitution mapping where the old resource name will be replaced by the new resource name automatically prior to the request being processed.
* @param oldName The old resource name.

View File

@@ -223,6 +223,11 @@ public String getErrorHeader(int errorCode) {
public ISession getSession(String sessionId) {
return null;
}//getSession()//
/* (non-Javadoc)
* @see com.foundation.web.interfaces.IWebApplication#handleWebSocketUpgrade(com.foundation.web.interfaces.IRequest, com.foundation.web.interfaces.IResponse, com.foundation.web.interfaces.ISession, boolean, boolean, com.foundation.web.interfaces.IConnectionContext, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
public void handleWebSocketUpgrade(IRequest request, IResponse response, ISession session, boolean isSecure, boolean clientHadBadSession, IConnectionContext connectionContext, String connection, String secWebSocketKey, String secWebSocketProtocol, String secWebSocketVersion, String origin) {
}//handleWebSocketUpgrade()//
/* (non-Javadoc)
* @see com.foundation.web.interfaces.IWebApplication#processRequest(com.foundation.web.interfaces.IRequest, com.foundation.web.interfaces.IResponse, com.foundation.web.interfaces.ISession, boolean, boolean, com.foundation.web.interfaces.IConnectionContext)
*/

View File

@@ -85,4 +85,6 @@ public interface IWebServerApplicationDefaults {
"<h2>For Apple Safari</h2>" +
"<p>Safari has a built in auto update system, but if you are still having problems you can reinstall it: Go to the <a href='http://www.apple.com/safari/'>Apple Safari</a> website and click the \"Download Now\" link and follow the instructions.</p>" +
"</TD></TR></TABLE></BODY></HTML>";
public static final String UPGRADE_FAILED =
"Socket upgrade request failed or was rejected.";
}//IWebServerApplicationDefaults//

View File

@@ -262,6 +262,12 @@ public String getErrorHeader(int errorCode) {
public ISession getSession(String sessionId) {
return null;
}//getSession()//
/* (non-Javadoc)
* @see com.foundation.web.interfaces.IWebApplication#handleWebSocketUpgrade(com.foundation.web.interfaces.IRequest, com.foundation.web.interfaces.IResponse, com.foundation.web.interfaces.ISession, boolean, boolean, com.foundation.web.interfaces.IConnectionContext, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
public void handleWebSocketUpgrade(IRequest request, IResponse response, ISession session, boolean isSecure, boolean clientHadBadSession, IConnectionContext connectionContext, String connection, String secWebSocketKey, String secWebSocketProtocol, String secWebSocketVersion, String origin) {
//Shouldn't ever get here I don't think.//
}//handleWebSocketUpgrade()//
/* (non-Javadoc)
* @see com.foundation.web.interfaces.IWebApplication#processRequest(com.foundation.web.interfaces.IRequest, com.foundation.web.interfaces.IResponse, com.foundation.web.interfaces.ISession, boolean, boolean, com.foundation.web.interfaces.IConnectionContext)
*/

View File

@@ -47,6 +47,10 @@ public ResourceRequestHandler() {
Debug.log("Failed to read the framework.js file from the framework jar.", e);
}//catch//
}//ResourceRequestHandler()//
/**
* Gives the web application a chance to handle the web socket upgrade.
*/
public abstract void processWebSocketUpgrade(IRequest request, IResponse response, ISession session, boolean isSecure, boolean clientHadBadSession, IConnectionContext connectionContext, String connection, String secWebSocketKey, String secWebSocketProtocol, String secWebSocketVersion, String origin);
/**
* Allows the handler to substitute one path for another.
* @param path The path that was provided by the client.

View File

@@ -642,6 +642,10 @@ public IContent getErrorContent(int errorCode) {
result = new HtmlContent(TLS_FAILURE);
break;
}//case//
case IResponse.ERROR_UPGRADE_REJECTED: {
result = new HtmlContent(UPGRADE_FAILED);
break;
}//case//
}//case//
return result;
@@ -670,10 +674,25 @@ public String getErrorHeader(int errorCode) {
result = "HTTP/1.1 200 Browser Upgrade Required\r\n";
break;
}//case//
case IResponse.ERROR_UPGRADE_REJECTED: {
result = "HTTP/1.1 100 Socket Upgrade Failed/Rejected\r\n";
break;
}//case//
}//case//
return result;
}//getErrorHeader()//
/* (non-Javadoc)
* @see com.foundation.web.interfaces.IWebApplication#handleWebSocketUpgrade(com.foundation.web.interfaces.IRequest, com.foundation.web.interfaces.IResponse, com.foundation.web.interfaces.ISession, boolean, boolean, com.foundation.web.interfaces.IConnectionContext, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
public void handleWebSocketUpgrade(IRequest request, IResponse response, ISession session, boolean isSecure, boolean clientHadBadSession, IConnectionContext connectionContext, String connection, String secWebSocketKey, String secWebSocketProtocol, String secWebSocketVersion, String origin) {
if(resourceRequestHandler != null) {
resourceRequestHandler.processWebSocketUpgrade(request, response, session, isSecure, clientHadBadSession, connectionContext, connection, secWebSocketKey, secWebSocketProtocol, secWebSocketVersion, origin);
}//if//
else {
response.setError(IResponse.ERROR_UPGRADE_REJECTED);
}//else//
}//handleWebSocketUpgrade()//
/* (non-Javadoc)
* @see com.foundation.web.interfaces.IWebApplication#processRequest(com.foundation.web.interfaces.IRequest, com.foundation.web.interfaces.IResponse, com.foundation.web.interfaces.ISession, boolean, boolean, com.foundation.web.interfaces.IConnectionContext)
*/