1
1
package io .quarkus .netty .runtime .graal ;
2
2
3
+ import static io .netty .handler .codec .http .HttpHeaderValues .BR ;
3
4
import static io .netty .handler .codec .http .HttpHeaderValues .DEFLATE ;
4
5
import static io .netty .handler .codec .http .HttpHeaderValues .GZIP ;
5
6
import static io .netty .handler .codec .http .HttpHeaderValues .X_DEFLATE ;
43
44
import io .netty .buffer .ByteBufAllocator ;
44
45
import io .netty .channel .Channel ;
45
46
import io .netty .channel .ChannelFuture ;
46
- import io .netty .channel .ChannelHandler ;
47
47
import io .netty .channel .ChannelHandlerContext ;
48
48
import io .netty .channel .DefaultChannelPromise ;
49
49
import io .netty .channel .embedded .EmbeddedChannel ;
50
+ import io .netty .handler .codec .compression .Brotli ;
51
+ import io .netty .handler .codec .compression .BrotliDecoder ;
50
52
import io .netty .handler .codec .compression .ZlibCodecFactory ;
51
53
import io .netty .handler .codec .compression .ZlibWrapper ;
52
- import io .netty .handler .codec .http .HttpHeaderValues ;
53
54
import io .netty .handler .codec .http2 .Http2Exception ;
54
55
import io .netty .handler .ssl .ApplicationProtocolConfig ;
55
56
import io .netty .handler .ssl .ApplicationProtocolConfig .SelectorFailureBehavior ;
@@ -518,6 +519,10 @@ protected EmbeddedChannel newContentDecoder(String contentEncoding) throws Excep
518
519
return new EmbeddedChannel (ctx .channel ().id (), ctx .channel ().metadata ().hasDisconnect (),
519
520
ctx .channel ().config (), ZlibCodecFactory .newZlibDecoder (wrapper ));
520
521
}
522
+ if (Brotli .isAvailable () && BR .contentEqualsIgnoreCase (contentEncoding )) {
523
+ return new EmbeddedChannel (ctx .channel ().id (), ctx .channel ().metadata ().hasDisconnect (),
524
+ ctx .channel ().config (), new BrotliDecoder ());
525
+ }
521
526
522
527
// 'identity' or unsupported
523
528
return null ;
@@ -533,21 +538,23 @@ final class Target_io_netty_handler_codec_http2_DelegatingDecompressorFrameListe
533
538
@ Substitute
534
539
protected EmbeddedChannel newContentDecompressor (ChannelHandlerContext ctx , CharSequence contentEncoding )
535
540
throws Http2Exception {
536
- if (!HttpHeaderValues .GZIP .contentEqualsIgnoreCase (contentEncoding )
537
- && !HttpHeaderValues .X_GZIP .contentEqualsIgnoreCase (contentEncoding )) {
538
- if (!HttpHeaderValues .DEFLATE .contentEqualsIgnoreCase (contentEncoding )
539
- && !HttpHeaderValues .X_DEFLATE .contentEqualsIgnoreCase (contentEncoding )) {
540
- return null ;
541
- } else {
542
- ZlibWrapper wrapper = this .strict ? ZlibWrapper .ZLIB : ZlibWrapper .ZLIB_OR_NONE ;
543
- return new EmbeddedChannel (ctx .channel ().id (), ctx .channel ().metadata ().hasDisconnect (),
544
- ctx .channel ().config (),
545
- new ChannelHandler [] { ZlibCodecFactory .newZlibDecoder (wrapper ) });
546
- }
547
- } else {
548
- return new EmbeddedChannel (ctx .channel ().id (), ctx .channel ().metadata ().hasDisconnect (), ctx .channel ().config (),
549
- new ChannelHandler [] { ZlibCodecFactory .newZlibDecoder (ZlibWrapper .GZIP ) });
541
+ if (GZIP .contentEqualsIgnoreCase (contentEncoding ) || X_GZIP .contentEqualsIgnoreCase (contentEncoding )) {
542
+ return new EmbeddedChannel (ctx .channel ().id (), ctx .channel ().metadata ().hasDisconnect (),
543
+ ctx .channel ().config (), ZlibCodecFactory .newZlibDecoder (ZlibWrapper .GZIP ));
550
544
}
545
+ if (DEFLATE .contentEqualsIgnoreCase (contentEncoding ) || X_DEFLATE .contentEqualsIgnoreCase (contentEncoding )) {
546
+ final ZlibWrapper wrapper = strict ? ZlibWrapper .ZLIB : ZlibWrapper .ZLIB_OR_NONE ;
547
+ // To be strict, 'deflate' means ZLIB, but some servers were not implemented correctly.
548
+ return new EmbeddedChannel (ctx .channel ().id (), ctx .channel ().metadata ().hasDisconnect (),
549
+ ctx .channel ().config (), ZlibCodecFactory .newZlibDecoder (wrapper ));
550
+ }
551
+ if (Brotli .isAvailable () && BR .contentEqualsIgnoreCase (contentEncoding )) {
552
+ return new EmbeddedChannel (ctx .channel ().id (), ctx .channel ().metadata ().hasDisconnect (),
553
+ ctx .channel ().config (), new BrotliDecoder ());
554
+ }
555
+
556
+ // 'identity' or unsupported
557
+ return null ;
551
558
}
552
559
}
553
560
0 commit comments