Skip to content

Commit 60eadb7

Browse files
committed
switch to 4.1.0.CR1-SNAPSHOT, see netty/netty#4593
1 parent dece6cc commit 60eadb7

File tree

3 files changed

+36
-26
lines changed

3 files changed

+36
-26
lines changed

client/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
<dependency>
2929
<groupId>io.netty</groupId>
3030
<artifactId>netty-codec-http</artifactId>
31-
<version>4.1.0.Beta8</version>
31+
<version>4.1.0.CR1-SNAPSHOT</version>
3232
</dependency>
3333
<dependency>
3434
<groupId>io.netty</groupId>
3535
<artifactId>netty-handler</artifactId>
36-
<version>4.1.0.Beta8</version>
36+
<version>4.1.0.CR1-SNAPSHOT</version>
3737
</dependency>
3838
<dependency>
3939
<groupId>org.reactivestreams</groupId>
@@ -43,7 +43,7 @@
4343
<dependency>
4444
<groupId>com.typesafe.netty</groupId>
4545
<artifactId>netty-reactive-streams</artifactId>
46-
<version>1.0.0</version>
46+
<version>1.0.1</version>
4747
<exclusions>
4848
<exclusion>
4949
<groupId>io.netty</groupId>

client/src/main/java/org/asynchttpclient/netty/channel/ChannelManager.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,13 @@ public static boolean isSslHandlerConfigured(ChannelPipeline pipeline) {
398398
}
399399

400400
public void upgradeProtocol(ChannelPipeline pipeline, Uri requestUri) throws SSLException {
401-
if (pipeline.get("HttpClientCodec$Decoder#0") != null) {
402-
pipeline.remove("HttpClientCodec$Decoder#0");
403-
pipeline.remove("HttpClientCodec$Encoder#0");
404-
}
401+
402+
if (pipeline.get(HTTP_CLIENT_CODEC) != null)
403+
pipeline.remove(HTTP_CLIENT_CODEC);
404+
// if (pipeline.get("HttpClientCodec$Decoder#0") != null) {
405+
// pipeline.remove("HttpClientCodec$Decoder#0");
406+
// pipeline.remove("HttpClientCodec$Encoder#0");
407+
// }
405408

406409
if (requestUri.isSecured())
407410
if (isSslHandlerConfigured(pipeline)) {
@@ -450,12 +453,14 @@ public Bootstrap getBootstrap(Uri uri, ProxyServer proxy) {
450453

451454
public void upgradePipelineForWebSockets(ChannelPipeline pipeline) {
452455

453-
// HttpClientCodec$Decoder#0
454-
// HttpClientCodec$Encoder#0
455-
456-
pipeline.addAfter("HttpClientCodec$Encoder#0", WS_ENCODER_HANDLER, new WebSocket08FrameEncoder(true));
457-
pipeline.remove("HttpClientCodec$Decoder#0");
458-
pipeline.remove("HttpClientCodec$Encoder#0");
456+
// pipeline.addAfter(HTTP_CLIENT_CODEC, WS_ENCODER_HANDLER, new WebSocket08FrameEncoder(true));
457+
pipeline.addBefore(AHC_WS_HANDLER, WS_ENCODER_HANDLER, new WebSocket08FrameEncoder(true));
458+
pipeline.remove(HTTP_CLIENT_CODEC);
459+
// HttpClientCodec$Decoder#0
460+
// HttpClientCodec$Encoder#0
461+
// pipeline.addAfter("HttpClientCodec$Encoder#0", WS_ENCODER_HANDLER, new WebSocket08FrameEncoder(true));
462+
// pipeline.remove("HttpClientCodec$Decoder#0");
463+
// pipeline.remove("HttpClientCodec$Encoder#0");
459464
pipeline.addBefore(AHC_WS_HANDLER, WS_DECODER_HANDLER, new WebSocket08FrameDecoder(false, false, config.getWebSocketMaxFrameSize()));
460465
pipeline.addAfter(WS_DECODER_HANDLER, WS_FRAME_AGGREGATOR, new WebSocketFrameAggregator(config.getWebSocketMaxBufferSize()));
461466
}

client/src/main/java/org/asynchttpclient/netty/request/body/BodyChunkedInput.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import static org.asynchttpclient.util.Assertions.assertNotNull;
1717
import io.netty.buffer.ByteBuf;
18+
import io.netty.buffer.ByteBufAllocator;
1819
import io.netty.channel.ChannelHandlerContext;
1920
import io.netty.handler.stream.ChunkedInput;
2021

@@ -45,24 +46,28 @@ public BodyChunkedInput(Body body) {
4546

4647
@Override
4748
public ByteBuf readChunk(ChannelHandlerContext ctx) throws Exception {
49+
return readChunk(ctx.alloc());
50+
}
4851

52+
@Override
53+
public ByteBuf readChunk(ByteBufAllocator allocator) throws Exception {
4954
if (endOfInput)
5055
return null;
5156

52-
ByteBuf buffer = ctx.alloc().buffer(chunkSize);
57+
ByteBuf buffer = allocator.buffer(chunkSize);
5358
Body.BodyState state = body.transferTo(buffer);
5459
progress += buffer.readableBytes();
5560
switch (state) {
56-
case STOP:
57-
endOfInput = true;
58-
return buffer;
59-
case SUSPEND:
60-
//this will suspend the stream in ChunkedWriteHandler
61-
return null;
62-
case CONTINUE:
63-
return buffer;
64-
default:
65-
throw new IllegalStateException("Unknown state: " + state);
61+
case STOP:
62+
endOfInput = true;
63+
return buffer;
64+
case SUSPEND:
65+
// this will suspend the stream in ChunkedWriteHandler
66+
return null;
67+
case CONTINUE:
68+
return buffer;
69+
default:
70+
throw new IllegalStateException("Unknown state: " + state);
6671
}
6772
}
6873

@@ -75,12 +80,12 @@ public boolean isEndOfInput() throws Exception {
7580
public void close() throws Exception {
7681
body.close();
7782
}
78-
83+
7984
@Override
8085
public long progress() {
8186
return progress;
8287
}
83-
88+
8489
@Override
8590
public long length() {
8691
return length;

0 commit comments

Comments
 (0)