Merge remote-tracking branch 'origin/jetty-9.4.x'
This commit is contained in:
commit
25a9a35be0
|
@ -203,49 +203,83 @@ public class MimeTypes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String resourceName = "org/eclipse/jetty/http/mime";
|
String resourceName = "org/eclipse/jetty/http/mime.properties";
|
||||||
try
|
try (InputStream stream = MimeTypes.class.getClassLoader().getResourceAsStream(resourceName))
|
||||||
{
|
{
|
||||||
ResourceBundle mimeBundle = ResourceBundle.getBundle(resourceName);
|
if (stream == null)
|
||||||
mimeBundle.keySet().stream()
|
|
||||||
.filter(x->x!=null)
|
|
||||||
.forEach(x->
|
|
||||||
__dftMimeMap.put(StringUtil.asciiToLowerCase(x), normalizeMimeType(mimeBundle.getString(x))));
|
|
||||||
|
|
||||||
if (__dftMimeMap.size()==0)
|
|
||||||
{
|
{
|
||||||
LOG.warn("Empty mime types at {}", resourceName);
|
LOG.warn("Missing mime-type resource: {}", resourceName);
|
||||||
}
|
}
|
||||||
else if (__dftMimeMap.size()<mimeBundle.keySet().size())
|
else
|
||||||
{
|
{
|
||||||
LOG.warn("Duplicate or null mime-type extension in resource: {}", resourceName);
|
try (InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8))
|
||||||
}
|
{
|
||||||
}
|
Properties props = new Properties();
|
||||||
catch (MissingResourceException e)
|
props.load(reader);
|
||||||
{
|
props.stringPropertyNames().stream()
|
||||||
LOG.warn("Missing mime-type resource: {}", resourceName);
|
.filter(x->x!=null)
|
||||||
}
|
.forEach(x->
|
||||||
|
__dftMimeMap.put(StringUtil.asciiToLowerCase(x), normalizeMimeType(props.getProperty(x))));
|
||||||
|
|
||||||
resourceName = "org/eclipse/jetty/http/encoding";
|
if (__dftMimeMap.size()==0)
|
||||||
try
|
{
|
||||||
{
|
LOG.warn("Empty mime types at {}", resourceName);
|
||||||
ResourceBundle encodingBundle = ResourceBundle.getBundle(resourceName);
|
}
|
||||||
encodingBundle.keySet().stream()
|
else if (__dftMimeMap.size()<props.keySet().size())
|
||||||
.filter(t->t!=null)
|
{
|
||||||
.forEach(t->__encodings.put(t, encodingBundle.getString(t)));
|
LOG.warn("Duplicate or null mime-type extension in resource: {}", resourceName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
LOG.warn(e.toString());
|
||||||
|
LOG.debug(e);
|
||||||
|
}
|
||||||
|
|
||||||
if (__encodings.size()==0)
|
|
||||||
{
|
|
||||||
LOG.warn("Empty encodings at {}", resourceName);
|
|
||||||
}
|
|
||||||
else if (__encodings.size()<encodingBundle.keySet().size())
|
|
||||||
{
|
|
||||||
LOG.warn("Null or duplicate encodings in resource: {}", resourceName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (MissingResourceException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOG.warn("Missing encoding resource: {}", resourceName);
|
LOG.warn(e.toString());
|
||||||
|
LOG.debug(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
resourceName = "org/eclipse/jetty/http/encoding.properties";
|
||||||
|
try (InputStream stream = MimeTypes.class.getClassLoader().getResourceAsStream(resourceName))
|
||||||
|
{
|
||||||
|
if (stream == null)
|
||||||
|
LOG.warn("Missing encoding resource: {}", resourceName);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try (InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8))
|
||||||
|
{
|
||||||
|
Properties props = new Properties();
|
||||||
|
props.load(reader);
|
||||||
|
props.stringPropertyNames().stream()
|
||||||
|
.filter(t->t!=null)
|
||||||
|
.forEach(t->__encodings.put(t, props.getProperty(t)));
|
||||||
|
|
||||||
|
if (__encodings.size()==0)
|
||||||
|
{
|
||||||
|
LOG.warn("Empty encodings at {}", resourceName);
|
||||||
|
}
|
||||||
|
else if (__encodings.size()<props.keySet().size())
|
||||||
|
{
|
||||||
|
LOG.warn("Null or duplicate encodings in resource: {}", resourceName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
LOG.warn(e.toString());
|
||||||
|
LOG.debug(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
LOG.warn(e.toString());
|
||||||
|
LOG.debug(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue