Skip to content

Commit 09ef5c0

Browse files
committed
Upgrade Netty 4.1.0.Beta8
1 parent 51653d8 commit 09ef5c0

37 files changed

+338
-351
lines changed

client/pom.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@
2828
<dependency>
2929
<groupId>io.netty</groupId>
3030
<artifactId>netty-codec-http</artifactId>
31-
<version>4.0.33.Final</version>
31+
<version>4.1.0.Beta8</version>
32+
</dependency>
33+
<dependency>
34+
<groupId>io.netty</groupId>
35+
<artifactId>netty-handler</artifactId>
36+
<version>4.1.0.Beta8</version>
3237
</dependency>
3338
<dependency>
3439
<groupId>org.reactivestreams</groupId>
@@ -39,6 +44,12 @@
3944
<groupId>com.typesafe.netty</groupId>
4045
<artifactId>netty-reactive-streams</artifactId>
4146
<version>1.0.0</version>
47+
<exclusions>
48+
<exclusion>
49+
<groupId>io.netty</groupId>
50+
<artifactId>netty-handler</artifactId>
51+
</exclusion>
52+
</exclusions>
4253
</dependency>
4354
<dependency>
4455
<groupId>org.javassist</groupId>

client/src/main/java/org/asynchttpclient/RequestBuilderBase.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static org.asynchttpclient.util.HttpUtils.*;
1919
import static org.asynchttpclient.util.MiscUtils.isNonEmpty;
2020
import io.netty.handler.codec.http.DefaultHttpHeaders;
21+
import io.netty.handler.codec.http.HttpHeaderNames;
2122
import io.netty.handler.codec.http.HttpHeaders;
2223

2324
import java.io.File;
@@ -167,7 +168,7 @@ public T setVirtualHost(String virtualHost) {
167168
return asDerivedType();
168169
}
169170

170-
public T setHeader(CharSequence name, String value) {
171+
public T setHeader(CharSequence name, CharSequence value) {
171172
this.headers.set(name, value);
172173
return asDerivedType();
173174
}
@@ -486,7 +487,7 @@ private RequestBuilderBase<?> executeSignatureCalculator() {
486487
private Charset computeCharset() {
487488
if (this.charset == null) {
488489
try {
489-
final String contentType = this.headers.get(HttpHeaders.Names.CONTENT_TYPE);
490+
final String contentType = this.headers.get(HttpHeaderNames.CONTENT_TYPE);
490491
if (contentType != null) {
491492
final Charset charset = parseCharset(contentType);
492493
if (charset != null) {
@@ -507,7 +508,7 @@ private Charset computeCharset() {
507508
private long computeRequestContentLength() {
508509
if (this.contentLength < 0 && this.streamData == null) {
509510
// can't concatenate content-length
510-
final String contentLength = this.headers.get(HttpHeaders.Names.CONTENT_LENGTH);
511+
final String contentLength = this.headers.get(HttpHeaderNames.CONTENT_LENGTH);
511512

512513
if (contentLength != null) {
513514
try {

client/src/main/java/org/asynchttpclient/Response.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
*/
1717
package org.asynchttpclient;
1818

19-
import org.asynchttpclient.cookie.Cookie;
20-
import org.asynchttpclient.netty.NettyResponse;
21-
import org.asynchttpclient.uri.Uri;
22-
2319
import io.netty.handler.codec.http.HttpHeaders;
2420

2521
import java.io.InputStream;
@@ -29,6 +25,10 @@
2925
import java.util.ArrayList;
3026
import java.util.List;
3127

28+
import org.asynchttpclient.cookie.Cookie;
29+
import org.asynchttpclient.netty.NettyResponse;
30+
import org.asynchttpclient.uri.Uri;
31+
3232
/**
3333
* Represents the asynchronous HTTP response callback for an {@link AsyncCompletionHandler}
3434
*/
@@ -101,15 +101,15 @@ public interface Response {
101101
* @param name the header name
102102
* @return the first response header value
103103
*/
104-
String getHeader(String name);
104+
String getHeader(CharSequence name);
105105

106106
/**
107107
* Return a {@link List} of the response header value.
108108
*
109109
* @param name the header name
110110
* @return the response header value
111111
*/
112-
List<String> getHeaders(String name);
112+
List<String> getHeaders(CharSequence name);
113113

114114
HttpHeaders getHeaders();
115115

client/src/main/java/org/asynchttpclient/channel/KeepAliveStrategy.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
*/
1414
package org.asynchttpclient.channel;
1515

16-
import static io.netty.handler.codec.http.HttpHeaders.Names.CONNECTION;
17-
import static io.netty.handler.codec.http.HttpHeaders.Values.*;
16+
import static io.netty.handler.codec.http.HttpHeaderNames.CONNECTION;
17+
import static io.netty.handler.codec.http.HttpHeaderValues.*;
1818
import io.netty.handler.codec.http.HttpMessage;
1919
import io.netty.handler.codec.http.HttpRequest;
2020
import io.netty.handler.codec.http.HttpResponse;
@@ -34,7 +34,7 @@ public interface KeepAliveStrategy {
3434
boolean keepAlive(Request ahcRequest, HttpRequest nettyRequest, HttpResponse nettyResponse);
3535

3636
/**
37-
* Connection strategy implementing standard HTTP 1.0/1.1 behaviour.
37+
* Connection strategy implementing standard HTTP 1.0/1.1 behavior.
3838
*/
3939
enum DefaultKeepAliveStrategy implements KeepAliveStrategy {
4040

@@ -49,18 +49,18 @@ public boolean keepAlive(Request ahcRequest, HttpRequest request, HttpResponse r
4949

5050
String responseConnectionHeader = connectionHeader(response);
5151

52-
if (CLOSE.equalsIgnoreCase(responseConnectionHeader)) {
52+
if (CLOSE.contentEqualsIgnoreCase(responseConnectionHeader)) {
5353
return false;
5454
} else {
5555
String requestConnectionHeader = connectionHeader(request);
5656

57-
if (request.getProtocolVersion() == HttpVersion.HTTP_1_0) {
57+
if (request.protocolVersion() == HttpVersion.HTTP_1_0) {
5858
// only use keep-alive if both parties agreed upon it
59-
return KEEP_ALIVE.equalsIgnoreCase(requestConnectionHeader) && KEEP_ALIVE.equalsIgnoreCase(responseConnectionHeader);
59+
return KEEP_ALIVE.contentEqualsIgnoreCase(requestConnectionHeader) && KEEP_ALIVE.contentEqualsIgnoreCase(responseConnectionHeader);
6060

6161
} else {
6262
// 1.1+, keep-alive is default behavior
63-
return !CLOSE.equalsIgnoreCase(requestConnectionHeader);
63+
return !CLOSE.contentEqualsIgnoreCase(requestConnectionHeader);
6464
}
6565
}
6666
}

client/src/main/java/org/asynchttpclient/handler/resumable/ResumableAsyncHandler.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212
*/
1313
package org.asynchttpclient.handler.resumable;
1414

15+
import io.netty.handler.codec.http.HttpHeaderNames;
16+
17+
import java.io.IOException;
18+
import java.nio.ByteBuffer;
19+
import java.util.HashMap;
20+
import java.util.Map;
21+
import java.util.concurrent.ConcurrentLinkedQueue;
22+
import java.util.concurrent.atomic.AtomicLong;
23+
1524
import org.asynchttpclient.AsyncHandler;
1625
import org.asynchttpclient.HttpResponseBodyPart;
1726
import org.asynchttpclient.HttpResponseHeaders;
@@ -24,15 +33,6 @@
2433
import org.slf4j.Logger;
2534
import org.slf4j.LoggerFactory;
2635

27-
import io.netty.handler.codec.http.HttpHeaders;
28-
29-
import java.io.IOException;
30-
import java.nio.ByteBuffer;
31-
import java.util.HashMap;
32-
import java.util.Map;
33-
import java.util.concurrent.ConcurrentLinkedQueue;
34-
import java.util.concurrent.atomic.AtomicLong;
35-
3636
/**
3737
* An {@link AsyncHandler} which support resumable download, e.g when used with an {@link ResumableIOExceptionFilter},
3838
* this handler can resume the download operation at the point it was before the interruption occurred. This prevent having to
@@ -177,7 +177,7 @@ public Response onCompleted() throws Exception {
177177
@Override
178178
public AsyncHandler.State onHeadersReceived(HttpResponseHeaders headers) throws Exception {
179179
responseBuilder.accumulate(headers);
180-
String contentLengthHeader = headers.getHeaders().get(HttpHeaders.Names.CONTENT_LENGTH);
180+
String contentLengthHeader = headers.getHeaders().get(HttpHeaderNames.CONTENT_LENGTH);
181181
if (contentLengthHeader != null) {
182182
if (Long.parseLong(contentLengthHeader) == -1L) {
183183
return AsyncHandler.State.ABORT;
@@ -210,8 +210,8 @@ public Request adjustRequestRange(Request request) {
210210
}
211211

212212
RequestBuilder builder = new RequestBuilder(request);
213-
if (request.getHeaders().get(HttpHeaders.Names.RANGE) == null && byteTransferred.get() != 0) {
214-
builder.setHeader(HttpHeaders.Names.RANGE, "bytes=" + byteTransferred.get() + "-");
213+
if (request.getHeaders().get(HttpHeaderNames.RANGE) == null && byteTransferred.get() != 0) {
214+
builder.setHeader(HttpHeaderNames.RANGE, "bytes=" + byteTransferred.get() + "-");
215215
}
216216
return builder.build();
217217
}

client/src/main/java/org/asynchttpclient/netty/NettyResponse.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
*/
1414
package org.asynchttpclient.netty;
1515

16-
import static io.netty.handler.codec.http.HttpHeaders.Names.*;
16+
import static io.netty.handler.codec.http.HttpHeaderNames.*;
1717
import static org.asynchttpclient.util.HttpUtils.*;
1818
import static org.asynchttpclient.util.MiscUtils.isNonEmpty;
19+
import io.netty.handler.codec.http.EmptyHttpHeaders;
1920
import io.netty.handler.codec.http.HttpHeaders;
2021

2122
import java.io.ByteArrayInputStream;
@@ -106,18 +107,18 @@ public final String getContentType() {
106107
}
107108

108109
@Override
109-
public final String getHeader(String name) {
110+
public final String getHeader(CharSequence name) {
110111
return headers != null ? getHeaders().get(name) : null;
111112
}
112113

113114
@Override
114-
public final List<String> getHeaders(String name) {
115+
public final List<String> getHeaders(CharSequence name) {
115116
return headers != null ? getHeaders().getAll(name) : Collections.<String> emptyList();
116117
}
117118

118119
@Override
119120
public final HttpHeaders getHeaders() {
120-
return headers != null ? headers.getHeaders() : HttpHeaders.EMPTY_HEADERS;
121+
return headers != null ? headers.getHeaders() : EmptyHttpHeaders.INSTANCE;
121122
}
122123

123124
@Override

client/src/main/java/org/asynchttpclient/netty/NettyResponseStatus.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public NettyResponseStatus(Uri uri, AsyncHttpClientConfig config, HttpResponse r
4949
* @return the response status code
5050
*/
5151
public int getStatusCode() {
52-
return response.getStatus().code();
52+
return response.status().code();
5353
}
5454

5555
/**
@@ -58,27 +58,27 @@ public int getStatusCode() {
5858
* @return the response status text
5959
*/
6060
public String getStatusText() {
61-
return response.getStatus().reasonPhrase();
61+
return response.status().reasonPhrase();
6262
}
6363

6464
@Override
6565
public String getProtocolName() {
66-
return response.getProtocolVersion().protocolName();
66+
return response.protocolVersion().protocolName();
6767
}
6868

6969
@Override
7070
public int getProtocolMajorVersion() {
71-
return response.getProtocolVersion().majorVersion();
71+
return response.protocolVersion().majorVersion();
7272
}
7373

7474
@Override
7575
public int getProtocolMinorVersion() {
76-
return response.getProtocolVersion().minorVersion();
76+
return response.protocolVersion().minorVersion();
7777
}
7878

7979
@Override
8080
public String getProtocolText() {
81-
return response.getProtocolVersion().text();
81+
return response.protocolVersion().text();
8282
}
8383

8484
@Override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private void abortChannelPreemption() {
6363

6464
private void writeRequest(Channel channel) {
6565

66-
LOGGER.debug("Using non-cached Channel {} for {} '{}'", channel, future.getNettyRequest().getHttpRequest().getMethod(), future.getNettyRequest().getHttpRequest().getUri());
66+
LOGGER.debug("Using non-cached Channel {} for {} '{}'", channel, future.getNettyRequest().getHttpRequest().method(), future.getNettyRequest().getHttpRequest().uri());
6767

6868
Channels.setAttribute(channel, future);
6969

0 commit comments

Comments
 (0)