|
39 | 39 | import io.netty.util.Timer; |
40 | 40 | import io.netty.util.concurrent.*; |
41 | 41 | import io.netty.util.internal.StringUtil; |
| 42 | +import io.netty.util.internal.PlatformDependent; |
42 | 43 | import org.asynchttpclient.*; |
43 | 44 | import org.asynchttpclient.channel.ChannelPool; |
44 | 45 | import org.asynchttpclient.channel.ChannelPoolPartitioning; |
@@ -205,15 +206,20 @@ private Bootstrap newBootstrap(ChannelFactory<? extends Channel> channelFactory, |
205 | 206 |
|
206 | 207 | @SuppressWarnings("unchecked") |
207 | 208 | private TransportFactory<? extends Channel, ? extends EventLoopGroup> getNativeTransportFactory() { |
| 209 | + String nativeTransportFactoryClassName = null; |
| 210 | + if (PlatformDependent.isOsx()) { |
| 211 | + nativeTransportFactoryClassName = "org.asynchttpclient.netty.channel.KQueueTransportFactory"; |
| 212 | + } else if (!PlatformDependent.isWindows()) { |
| 213 | + nativeTransportFactoryClassName = "org.asynchttpclient.netty.channel.EpollTransportFactory"; |
| 214 | + } |
| 215 | + |
208 | 216 | try { |
209 | | - return (TransportFactory<? extends Channel, ? extends EventLoopGroup>) Class.forName("org.asynchttpclient.netty.channel.EpollTransportFactory").newInstance(); |
210 | | - } catch (Exception e) { |
211 | | - try { |
212 | | - return (TransportFactory<? extends Channel, ? extends EventLoopGroup>) Class.forName("org.asynchttpclient.netty.channel.KQueueTransportFactory").newInstance(); |
213 | | - } catch (Exception e1) { |
214 | | - throw new IllegalArgumentException("No suitable native transport (epoll or kqueue) available"); |
| 217 | + if (nativeTransportFactoryClassName != null) { |
| 218 | + return (TransportFactory<? extends Channel, ? extends EventLoopGroup>) Class.forName(nativeTransportFactoryClassName).newInstance(); |
215 | 219 | } |
| 220 | + } catch (Exception e) { |
216 | 221 | } |
| 222 | + throw new IllegalArgumentException("No suitable native transport (epoll or kqueue) available"); |
217 | 223 | } |
218 | 224 |
|
219 | 225 | private TransportFactory<? extends Channel, ? extends EventLoopGroup> getDomainTransportFactory() { |
@@ -382,6 +388,11 @@ public Future<Channel> updatePipelineForHttpTunneling(ChannelPipeline pipeline, |
382 | 388 |
|
383 | 389 | if (requestUri.isWebSocket()) { |
384 | 390 | pipeline.addAfter(AHC_HTTP_HANDLER, AHC_WS_HANDLER, wsHandler); |
| 391 | + |
| 392 | + if (config.isEnableWebSocketCompression()) { |
| 393 | + pipeline.addBefore(AHC_WS_HANDLER, WS_COMPRESSOR_HANDLER, WebSocketClientCompressionHandler.INSTANCE); |
| 394 | + } |
| 395 | + |
385 | 396 | pipeline.remove(AHC_HTTP_HANDLER); |
386 | 397 | } |
387 | 398 | return whenHanshaked; |
|
0 commit comments