File tree Expand file tree Collapse file tree
httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -86,16 +86,19 @@ public ContentCompressionExec(
8686 final Lookup <InputStreamFactory > decoderRegistry ,
8787 final boolean ignoreUnknown ) {
8888
89- final boolean brotliSupported = BrotliDecompressingEntity .isAvailable ();
90- final List <String > encodings = new ArrayList <>(4 );
91- encodings .add ("gzip" );
92- encodings .add ("x-gzip" );
93- encodings .add ("deflate" );
94- if (brotliSupported ) {
95- encodings .add ("br" );
89+ final boolean brotliSupported = decoderRegistry == null && BrotliDecompressingEntity .isAvailable ();
90+ if (acceptEncoding != null ) {
91+ this .acceptEncoding = MessageSupport .headerOfTokens (HttpHeaders .ACCEPT_ENCODING , acceptEncoding );
92+ } else {
93+ final List <String > encodings = new ArrayList <>(4 );
94+ encodings .add ("gzip" );
95+ encodings .add ("x-gzip" );
96+ encodings .add ("deflate" );
97+ if (brotliSupported ) {
98+ encodings .add ("br" );
99+ }
100+ this .acceptEncoding = MessageSupport .headerOfTokens (HttpHeaders .ACCEPT_ENCODING , encodings );
96101 }
97- this .acceptEncoding = MessageSupport .headerOfTokens (HttpHeaders .ACCEPT_ENCODING , encodings );
98-
99102 if (decoderRegistry != null ) {
100103 this .decoderRegistry = decoderRegistry ;
101104 } else {
@@ -108,8 +111,6 @@ public ContentCompressionExec(
108111 }
109112 this .decoderRegistry = builder .build ();
110113 }
111-
112-
113114 this .ignoreUnknown = ignoreUnknown ;
114115 }
115116
You can’t perform that action at this time.
0 commit comments