io.undertow.servlet.api.MimeMapping Java Examples

The following examples show how to use io.undertow.servlet.api.MimeMapping. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContentTypeFilesTestCase.java    From quarkus-http with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setup() throws ServletException {
    final PathHandler root = new PathHandler();
    final ServletContainer container = ServletContainer.Factory.newInstance();

    DeploymentInfo builder = new DeploymentInfo()
            .setClassIntrospecter(TestClassIntrospector.INSTANCE)
            .setClassLoader(ContentTypeFilesTestCase.class.getClassLoader())
            .setContextPath("/app")
            .setDeploymentName("servletContext.war")
            .setResourceManager(new TestResourceLoader(ContentTypeServlet.class))
            .setDefaultServletConfig(new DefaultServletConfig(true))
            .addMimeMapping(new MimeMapping("jnlp", "application/x-java-jnlp-file"));

    DeploymentManager manager = container.addDeployment(builder);
    manager.deploy();
    root.addPrefixPath(builder.getContextPath(), manager.start());
    DefaultServer.setRootHandler(root);
}
 
Example #2
Source File: DeploymentManagerImpl.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
private void initializeMimeMappings(final DeploymentImpl deployment, final DeploymentInfo deploymentInfo) {
    final Map<String, String> mappings = new HashMap<>(MimeMappings.DEFAULT_MIME_MAPPINGS);
    for (MimeMapping mapping : deploymentInfo.getMimeMappings()) {
        mappings.put(mapping.getExtension().toLowerCase(Locale.ENGLISH), mapping.getMimeType());
    }
    deployment.setMimeExtensionMappings(mappings);
}
 
Example #3
Source File: DeploymentManagerImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private void initializeMimeMappings(final DeploymentImpl deployment, final DeploymentInfo deploymentInfo) {
    final Map<String, String> mappings = new HashMap<>(MimeMappings.DEFAULT_MIME_MAPPINGS);
    for (MimeMapping mapping : deploymentInfo.getMimeMappings()) {
        mappings.put(mapping.getExtension().toLowerCase(Locale.ENGLISH), mapping.getMimeType());
    }
    deployment.setMimeExtensionMappings(mappings);
}
 
Example #4
Source File: UndertowDeploymentRecorder.java    From quarkus with Apache License 2.0 4 votes vote down vote up
public void addMimeMapping(RuntimeValue<DeploymentInfo> info, String extension,
        String mimeType) throws Exception {
    info.getValue().addMimeMapping(new MimeMapping(extension, mimeType));
}
 
Example #5
Source File: HttpContentTypes.java    From jboot with Apache License 2.0 4 votes vote down vote up
/**
 * 让 undertow 支持音视频格式文件在线播放
 */
public static void init(DeploymentInfo di) {
   for (Map.Entry<String,String> entry : mappings.entrySet()){
       di.addMimeMapping(new MimeMapping(entry.getKey(),entry.getValue()));
   }
}