String host=request.getHost();
final int x=host.indexOf(':');
if(x>0) host=host.substring(0, x); // we only care about the host, we KNOW the port.
final Pair<String,String> newPath=config.getMount(host,request.getClientPort(),fullPathStr);
File finalFile;
final FileManager mgr=config.getFileManager();
if(newPath == null)
finalFile = mgr.createFileFromPath(fullPathStr.replace('/', mgr.getFileSeparator()));
else
{
String newFullPath=fullPathStr.substring(newPath.first.length());
if(newFullPath.startsWith("/")&&newPath.second.endsWith("/"))
newFullPath=newFullPath.substring(1);
finalFile=mgr.createFileFromPath((newPath.second+newFullPath).replace('/', mgr.getFileSeparator())); // subtract one for the /
}
// see if the path we have is complete, or if there's an implicit default page requested.
if(request.getUrlPath().endsWith("/"))
{
final File dirFile = finalFile;
finalFile=mgr.createFileFromPath(finalFile,config.getDefaultPage());
if((!finalFile.exists())&&(dirFile.exists())&&(dirFile.isDirectory()))
{
String browseCode = config.getBrowseCode(host,request.getClientPort(),fullPathStr);
if(browseCode != null) // it's allowed to be browsed
finalFile = dirFile;