Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The check for whether a mime type is gzipable modifies (lower-cases) the content type #4988

Closed
nickebbitt opened this issue Jun 22, 2020 · 2 comments · Fixed by #5248
Closed

Comments

@nickebbitt
Copy link

nickebbitt commented Jun 22, 2020

Jetty version

9.4.x (possibly others too)

Java version
1.8

OS type/version
Linux

Description
I'm not sure if this is by design or an issue but if you configure the GzipHandler a custom mime type in its include list that contains upper case characters, e.g. application/json+CUSTOM, then the handler fails to match the content type and therefore does not compress the response.

I've tracked this down to the following code:
https://github.com/eclipse/jetty.project/blob/jetty-9.4.x/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipHttpOutputInterceptor.java#L174

I'm aware that MIME types are generally lower-case by convention so it's possibly a design choice so does it make sense for both sides of the comparison to be lower-cased? If not a bug, is there any value in clarifying the behaviour in the docs?

@nickebbitt nickebbitt changed the title The check for whether a mime type is gzipable modifies (lower-cases) the response content type The check for whether a mime type is gzipable modifies (lower-cases) the content type Jun 22, 2020
@joakime
Copy link
Contributor

joakime commented Jun 22, 2020

As a workaround configure GzipHandler with the lowercase version, your use of the mixed case version from your application should still trigger.

Per https://tools.ietf.org/html/rfc7231#section-3.1.1.1
The type is case-insensitive in use.

In practice, Jetty operates on them in a lower-case version in code, but uses the case as-is from the application if the application is using HTTP/1.1 (or HTTP/1.0)
If the application is using HTTP/2 then the case is forced to lowercase to satisfy the HTTP/2 spec.

@nickebbitt
Copy link
Author

Thanks for the info @joakime - I had implemented the GzipHandler with the lower case version as you suggest and this works as expected.

lachlan-roberts added a commit that referenced this issue Sep 8, 2020
…sitive

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants