Fixed determining mime type of `PathResource` based on its file name. (#1532)

The result of `toString()` is expected to be the path name of a Resource. This is used for determining the mime type based on the file name extension in `org.eclipse.jetty.server.ResourceCache.Content`. Without a custom `toString()` implementation, no mime type can be determined for a resource. This problem does no longer exist in current Jetty, since `PathResource` has vanished.
This commit is contained in:
Bernhard Haumacher 2017-05-30 21:51:31 +02:00 committed by Greg Wilkins
parent 2baa1abe4b
commit 5e63c4db62
1 changed files with 8 additions and 0 deletions

View File

@ -201,6 +201,14 @@ public class PathResource extends Resource
return path.toAbsolutePath().toString();
}
@Override
public String toString() {
// Note: The org.eclipse.jetty.server.ResourceCache.Content uses #toString() instead of
// #getName() for determining the file name for mime type resolution based on the file name
// extension.
return _path.toString();
}
@Override
public ReadableByteChannel getReadableByteChannel() throws IOException
{