Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
parent
11ca0079e9
commit
b58cd5870b
|
@ -18,21 +18,24 @@
|
|||
|
||||
package org.eclipse.jetty.http;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jetty.util.ArrayTrie;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.Loader;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.Trie;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
@ -200,16 +203,41 @@ public class MimeTypes
|
|||
|
||||
try
|
||||
{
|
||||
ResourceBundle mime = ResourceBundle.getBundle("org/eclipse/jetty/http/mime");
|
||||
Enumeration<String> i = mime.getKeys();
|
||||
while(i.hasMoreElements())
|
||||
String resourceName = "org/eclipse/jetty/http/mime.properties";
|
||||
URL mimeTypesUrl = Loader.getResource(__dftMimeMap.getClass(), resourceName);
|
||||
if (mimeTypesUrl == null)
|
||||
{
|
||||
String ext = i.nextElement();
|
||||
String m = mime.getString(ext);
|
||||
__dftMimeMap.put(StringUtil.asciiToLowerCase(ext),normalizeMimeType(m));
|
||||
LOG.warn("Missing mime-type resource: {}", resourceName);
|
||||
}
|
||||
else
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
try (InputStream in = mimeTypesUrl.openStream();
|
||||
InputStreamReader reader = new InputStreamReader(in, StandardCharsets.UTF_8))
|
||||
{
|
||||
Properties mime = new Properties();
|
||||
mime.load(reader);
|
||||
|
||||
for (String ext : mime.stringPropertyNames())
|
||||
{
|
||||
if (ext == null)
|
||||
{
|
||||
LOG.warn("Encountered null mime-type extension in resource: {}", mimeTypesUrl);
|
||||
}
|
||||
String m = mime.getProperty(ext);
|
||||
__dftMimeMap.put(StringUtil.asciiToLowerCase(ext), normalizeMimeType(m));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count < 1)
|
||||
{
|
||||
LOG.warn("Empty mime types declaration at {}", mimeTypesUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(MissingResourceException e)
|
||||
catch(IOException e)
|
||||
{
|
||||
LOG.warn(e.toString());
|
||||
LOG.debug(e);
|
||||
|
@ -217,15 +245,40 @@ public class MimeTypes
|
|||
|
||||
try
|
||||
{
|
||||
ResourceBundle encoding = ResourceBundle.getBundle("org/eclipse/jetty/http/encoding");
|
||||
Enumeration<String> i = encoding.getKeys();
|
||||
while(i.hasMoreElements())
|
||||
String resourceName = "org/eclipse/jetty/http/encoding.properties";
|
||||
URL mimeTypesUrl = Loader.getResource(__dftMimeMap.getClass(), resourceName);
|
||||
if (mimeTypesUrl == null)
|
||||
{
|
||||
String type = i.nextElement();
|
||||
__encodings.put(type,encoding.getString(type));
|
||||
LOG.warn("Missing mime-type resource: {}", resourceName);
|
||||
}
|
||||
else
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
try (InputStream in = mimeTypesUrl.openStream();
|
||||
InputStreamReader reader = new InputStreamReader(in, StandardCharsets.UTF_8))
|
||||
{
|
||||
Properties encoding = new Properties();
|
||||
encoding.load(reader);
|
||||
|
||||
for (String type : encoding.stringPropertyNames())
|
||||
{
|
||||
if (type == null)
|
||||
{
|
||||
LOG.warn("Encountered null encoding type in resource: {}", mimeTypesUrl);
|
||||
}
|
||||
__encodings.put(type, encoding.getProperty(type));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count < 1)
|
||||
{
|
||||
LOG.warn("Empty mime types declaration at {}", mimeTypesUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(MissingResourceException e)
|
||||
catch(IOException e)
|
||||
{
|
||||
LOG.warn(e.toString());
|
||||
LOG.debug(e);
|
||||
|
|
Loading…
Reference in New Issue