Skip to content

How to exclude mime-types from compression? #14530

@lglowania

Description

@lglowania

Jetty Version
12.1.6
Jetty Environment
ee11
Java Version
25
Question

I'm trying to exclude mime-types from gzip-compression via jetty-compression.xml:

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
        "https://jetty.org/configure_10_0.dtd">

<Configure id="Server" class="org.eclipse.jetty.server.Server">
	<Call name="insertHandler">
		<Arg>
			<New class="org.eclipse.jetty.compression.server.CompressionHandler">
				<Call name="putConfiguration">
					<Arg>/*</Arg>
					<Arg>
						<Call
							class="org.eclipse.jetty.compression.server.CompressionConfig"
							name="builder">
							<Call name="compressExcludeMimeType">
								<Arg>audio/mp4</Arg>
							</Call>
							<Call name="compressExcludeMimeType">
								<Arg>audio/ogg</Arg>
							</Call>							
							<Call name="build" />
						</Call>
					</Arg>
				</Call>
			</New>
		</Arg>
	</Call>
</Configure>

The error i get is:

aused by: java.lang.RuntimeException: java.lang.IllegalStateException: No Method: <Call name="putConfiguration"><Arg>/*</Arg><Arg>
            
            <Call class="org.eclipse.jetty.compression.server.CompressionConfig" name="builder"><Call name="compressExcludeMimeType"><Arg>audio/mp4</Arg></Call><Call name="compressExcludeMimeType"><Arg>audio/ogg</Arg></Call><Call name="compressExcludeMimeType"><Arg>audio/flac</Arg></Call><Call name="build"/></Call>
            
          </Arg></Call> on class org.eclipse.jetty.compression.server.CompressionHandler
...
Caused by: java.lang.NoSuchMethodException: oejcs.CompressionHandler@4c4d362a{STOPPED,supported=} . putConfiguration(oejx.XmlConfiguration$JettyXmlConfiguration$Args@5400db36[null, null][/*, org.eclipse.jetty.compression.server.CompressionConfig$Builder@76b74e9c])
	at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.call(XmlConfiguration.java:1113)
	at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.call(XmlConfiguration.java:1070)
	... 16 more

So instead of the CompressionConfig, it uses the CompressionConfig$Builder. How can i use that Builder-pattern in jetty-IOC correctly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions