-
Notifications
You must be signed in to change notification settings - Fork 3.4k
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
It's too hard to turn off Gzip selectively #1673
Comments
Hello Dominik. Thanks for the report. I'd rather not change default behavior. I think the best and least-surgical solution would be to simply add accessor methods for excluded paths and MIME types to Can you clarify what you mean by "flushing fixed somehow?" Regarding the |
Thanks! Regarding flushing -- this is my theory: in the end you have a I did not invest the time to find out exactly how this works but my suspicion is (because the GZipHandler has no flush()) that there's just no mechanism to pass on the command: write out your buffers even if they're not yet filled up! So I suspect my nice SSE messages are hanging around in the 8kByte GZIP buffer...which especially with short messages takes some time to fill. Because AFAIK in general there's no reason why you couldn't compress that stream... Regarding the exposure in the API I have two thoughts:
|
Would additional GzipHandlerFactory configuration not solve your problem, though? We should focus on a near-term solution which solves your problem before considering wider refactoring work. While This is an interesting case, given that a preference for small, timely messages is fundamentally at odds with message compressibility. It seems to me that the |
Nice catch @evnm -- setting However a very fun thing happens in Chrome (53.0.2785.57 beta (64-bit) on OS X to be precise)... With sync flush enabled everything works (JavaScript receives events) but while the thing is running the inspector doesn't show the events: Turn the compression off and you'll get a live preview: But that's really a non-issue. Thinking about it sync-flush is probably fine for most applications because typically we just have JAX-RS resources returning a full JSON (so no chunking at all, everything comes in one "big bang" -- sync-flush makes no difference in this situation) or we're heading for streaming and want a flush() to flush() 😄 So 👍 if this becomes configurable; thanks again! |
Weird. I have no idea how Chrome populates that EventStream tab, but I imagine that it's outside of Dropwizard's scope. Shifting discussion over to your PR from here. |
…fered. Upon later dropwizard upgrade we should consider a more fine tuned approach using 'syncFlush=true' fix from dropwizard/dropwizard#1673.
If you wanted to just completely turn off GZIP in Dropwizard 1.x endpoints, how would you do it? I'm trying to find out how to do it, it seems like the feature disappeared with 1.x |
@jimm-porch |
I wanted to use Jersey's SSE support with Dropwizard 1.0 however just as described in JERSEY-3000 Dropwizard by default has GZip-Compression. I somehow didn't want to go the easy way (just turn off Gzip), so I tried a lot:
@Context
ing all kind of ServletContextsDigging deeper I finally hit the underlying Jetty
GzipHandler
which happens to have the perfectexcludedPath
(exclude a path from Gzip treatment) andexcludedMimeTypes
(exclude a MIME type) methods that would not require me to re-create the positive whitelist of stuff that shall be Gzipped (supported in configuration)...I guess this should be the result of
getApplicationContext().getGzipHandler()
but this one isnull
no matter where in the lifecycle. I ended up learning something about Jetty and came up with this (which works nicely):I really think either MIME type
text/event-stream
should be excluded by default or flushing fixed somehow or at the blacklist be exposed for configuration or some special annotation to whitelist... No idea what is the most idiomatic way...The text was updated successfully, but these errors were encountered: