Skip to content

Commit 7d52ef4

Browse files
author
Stephane Landelle
committed
Minor clean up
1 parent 04c9514 commit 7d52ef4

File tree

4 files changed

+19
-23
lines changed

4 files changed

+19
-23
lines changed

api/src/main/java/org/asynchttpclient/HttpResponseBodyPart.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,23 @@ public HttpResponseBodyPart(URI uri, AsyncHttpProvider provider) {
3333
/**
3434
* Return length of this part in bytes.
3535
*
36-
* @since 1.8.0
36+
* @since 2.0.0
3737
*/
38-
abstract public int length();
38+
public abstract int length();
3939

4040
/**
4141
* Return the response body's part bytes received.
4242
*
4343
* @return the response body's part bytes received.
4444
*/
45-
abstract public byte[] getBodyPartBytes();
45+
public abstract byte[] getBodyPartBytes();
4646

4747
/**
4848
* Method for accessing contents of this part via stream.
4949
*
50-
* @since 1.8.0
50+
* @since 2.0.0
5151
*/
52-
abstract public InputStream readBodyPartBytes();
52+
public abstract InputStream readBodyPartBytes();
5353

5454
/**
5555
* Write the available bytes to the {@link java.io.OutputStream}
@@ -58,35 +58,35 @@ public HttpResponseBodyPart(URI uri, AsyncHttpProvider provider) {
5858
* @return The number of bytes written
5959
* @throws IOException
6060
*/
61-
abstract public int writeTo(OutputStream outputStream) throws IOException;
61+
public abstract int writeTo(OutputStream outputStream) throws IOException;
6262

6363
/**
6464
* Return a {@link ByteBuffer} that wraps the actual bytes read from the response's chunk. The {@link ByteBuffer}
6565
* capacity is equal to the number of bytes available.
6666
*
6767
* @return {@link ByteBuffer}
6868
*/
69-
abstract public ByteBuffer getBodyByteBuffer();
69+
public abstract ByteBuffer getBodyByteBuffer();
7070

7171
/**
7272
* Return true if this is the last part.
7373
*
7474
* @return true if this is the last part.
7575
*/
76-
abstract public boolean isLast();
76+
public abstract boolean isLast();
7777

7878
/**
7979
* Close the underlying connection once the processing has completed. Invoking that method means the
8080
* underlying TCP connection will be closed as soon as the processing of the response is completed. That
8181
* means the underlying connection will never get pooled.
8282
*/
83-
abstract public void markUnderlyingConnectionAsClosed();
83+
public abstract void markUnderlyingConnectionAsClosed();
8484

8585
/**
8686
* Return true of the underlying connection will be closed once the response has been fully processed.
8787
*
8888
* @return true of the underlying connection will be closed once the response has been fully processed.
8989
*/
90-
abstract public boolean closeUnderlyingConnection();
90+
public abstract boolean closeUnderlyingConnection();
9191

9292
}

providers/netty4/src/main/java/org/asynchttpclient/providers/netty4/Channels.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public void close() {
241241
}
242242
}
243243
openChannels.close();
244-
if (this.allowReleaseEventLoopGroup) {
244+
if (allowReleaseEventLoopGroup) {
245245
eventLoopGroup.shutdownGracefully();
246246
}
247247
}

providers/netty4/src/main/java/org/asynchttpclient/providers/netty4/NettyChannelHandler.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
import static io.netty.handler.codec.http.HttpResponseStatus.*;
44
import static org.asynchttpclient.providers.netty4.util.HttpUtil.*;
5-
import io.netty.buffer.Unpooled;
65
import io.netty.channel.Channel;
76
import io.netty.channel.ChannelHandler.Sharable;
87
import io.netty.channel.ChannelHandlerContext;
98
import io.netty.channel.ChannelInboundHandlerAdapter;
109
import io.netty.handler.codec.PrematureChannelClosureException;
11-
import io.netty.handler.codec.http.DefaultHttpContent;
1210
import io.netty.handler.codec.http.HttpClientCodec;
1311
import io.netty.handler.codec.http.HttpContent;
1412
import io.netty.handler.codec.http.HttpHeaders;
@@ -673,7 +671,7 @@ public void call() throws Exception {
673671

674672
if (!interrupt && chunk.content().readableBytes() > 0) {
675673
// FIXME why
676-
interrupt = updateBodyAndInterrupt(future, handler, new ResponseBodyPart(future.getURI(), chunk));
674+
interrupt = updateBodyAndInterrupt(future, handler, new ResponseBodyPart(future.getURI(), chunk.content(), last));
677675
}
678676

679677
if (interrupt || last) {
@@ -801,8 +799,7 @@ public void handle(ChannelHandlerContext ctx, NettyResponseFuture future, Object
801799
}
802800

803801
if (frame.content() != null && frame.content().readableBytes() > 0) {
804-
HttpContent webSocketChunk = new DefaultHttpContent(Unpooled.wrappedBuffer(frame.content()));
805-
ResponseBodyPart rp = new ResponseBodyPart(future.getURI(), webSocketChunk);
802+
ResponseBodyPart rp = new ResponseBodyPart(future.getURI(), frame.content(), frame.isFinalFragment());
806803
h.onBodyPartReceived(rp);
807804

808805
NettyWebSocket webSocket = NettyWebSocket.class.cast(h.onCompleted());

providers/netty4/src/main/java/org/asynchttpclient/providers/netty4/ResponseBodyPart.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
*/
1616
package org.asynchttpclient.providers.netty4;
1717

18-
import io.netty.handler.codec.http.HttpContent;
19-
import io.netty.handler.codec.http.LastHttpContent;
18+
import io.netty.buffer.ByteBuf;
2019

2120
import java.io.ByteArrayInputStream;
2221
import java.io.IOException;
@@ -34,14 +33,14 @@
3433
public class ResponseBodyPart extends HttpResponseBodyPart {
3534

3635
private final byte[] bytes;
37-
private final boolean isLast;
36+
private final boolean last;
3837
private boolean closeConnection = false;
3938

4039
// FIXME unused AsyncHttpProvider provider
41-
public ResponseBodyPart(URI uri, HttpContent chunk) {
40+
public ResponseBodyPart(URI uri, ByteBuf buf, boolean last) {
4241
super(uri, null);
43-
bytes = ByteBufUtil.byteBuf2bytes(chunk.content());
44-
isLast = chunk instanceof LastHttpContent;
42+
bytes = ByteBufUtil.byteBuf2bytes(buf);
43+
this.last = last;
4544
}
4645

4746
/**
@@ -80,7 +79,7 @@ public ByteBuffer getBodyByteBuffer() {
8079
*/
8180
@Override
8281
public boolean isLast() {
83-
return isLast;
82+
return last;
8483
}
8584

8685
/**

0 commit comments

Comments
 (0)