-
Notifications
You must be signed in to change notification settings - Fork 983
HTTPCLIENT-2375 Add first-class request-side compression support and pluggable encoders #657
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
Conversation
|
|
||
| @Internal | ||
| @Contract(threading = ThreadingBehavior.STATELESS) | ||
| public final class ContentEncoderRegistry { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arturobernalg There should provably be a single registry that can provide wrap / unwrap functions. InputStreamFactory should probably be deprecated. This however can be done with another change-set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ok2c I’ll take care of consolidating the encoder / decoder maps into a single registry (and marking InputStreamFactory for deprecation) in a follow-up change-set after this PR is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds like a good plan.
| /* ────────────────────────────────────────────── | ||
| 1. Tiny echo server that understands “br|zstd…” | ||
| ────────────────────────────────────────────── */ | ||
| final HttpServer server = HttpServer.create(new InetSocketAddress(0), 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arturobernalg Would not it be nicer to use our own HttpServer from core here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, we have to eat out of our own kitchen here 😉
130fa9a to
a845f36
Compare
...lient5/src/test/java/org/apache/hc/client5/http/examples/ClientServerCompressionExample.java
Fixed
Show fixed
Hide fixed
ok2c
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arturobernalg This warning looks legit and probably should be fixed. Otherwise looks good to me.
…pluggable encoders This change completes the work that began with the decoder registry (HTTPCLIENT-1843) by introducing a symmetric, service-loaded ContentEncoderRegistry and a concise, type-safe API on EntityBuilder. HttpClient will automatically wrap the chosen entity in the appropriate compressing wrapper, provided that the codec is available on the class-path (via Commons Compress or the built-in GZIP/deflate support).
624fdf3 to
b270606
Compare
Adds pluggable request-side compression. You can now call
EntityBuilder.compressed(ContentCoding)to have any codec discovered at runtime—GZIP remains the default, butBrotli,Zstandard,XZ, and the rest are picked up automatically when Commons Compress and the relevant helper JARs are on the class-path. The change introduces aContentEncoderRegistry, removes duplicate reflection probes via the newCommonsCompressSupport, keepsgzipCompressed()as a deprecated convenience alias, and ships a tinyZstdround-trip demo plus unit tests. No new mandatory dependencies; everything stays lightweight unless you choose to add more codecs.