Ktt-Development/simplehttpserver

File Handler - Null for file

Katsute opened this issue · 0 comments

Prerequisites

If all checks are not passed then the request will be closed

  • I have checked that no other similar feature request already exists
  • The feature request makes sense for the project

Proposal

Describe the feature that should be added

If a file is not found or is not allowed, still return the file reference instead of null reference

}else{ // beginning match
match = "";
for(final String key : directories.keySet())
if(rel.startsWith(key) && key.startsWith(match))
match = key;
if(!match.isEmpty() && directories.containsKey(match)){
final DirectoryEntry entry = directories.get(match);
final String rel2;
try{
rel2 = rel.substring(match.length());
if(entry.isFilesPreloaded()){
final File file;
if((file = entry.getFile(rel2)) != null){
handle(exchange, file, entry.getBytes(rel2)); // use adapted preload
}
}else{
final File file = new File(entry.getDirectory().getAbsolutePath() + "\\" + rel2);
handle(exchange,file,adapter.getBytes(file, Files.readAllBytes(file.toPath()))); // use adapted now
}
}catch(final IndexOutOfBoundsException ignored){ }
}
handle(exchange,null,null); // not found

Reasoning

Explain why this feature should be added

This would more configuration for null files, since it now has an association