Skip to content

Commit 586ed3e

Browse files
author
Stephane Landelle
committed
Status instances are not cached by the codec (message might change)
1 parent 87473b0 commit 586ed3e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,8 @@ private boolean applyIoExceptionFiltersAndReplayRequest(ChannelHandlerContext ct
243243
private boolean redirect(Request request, NettyResponseFuture<?> future, HttpResponse response, final ChannelHandlerContext ctx) throws Exception {
244244

245245
io.netty.handler.codec.http.HttpResponseStatus status = response.getStatus();
246-
// int statusCode = response.getStatus().code();
247246
boolean redirectEnabled = request.isRedirectOverrideSet() ? request.isRedirectEnabled() : config.isRedirectEnabled();
248-
boolean isRedirectStatus = status == MOVED_PERMANENTLY || status == FOUND || status == SEE_OTHER || status == TEMPORARY_REDIRECT;
247+
boolean isRedirectStatus = status.equals(MOVED_PERMANENTLY) || status.equals(FOUND) || status.equals(SEE_OTHER) || status.equals(TEMPORARY_REDIRECT);
249248
if (redirectEnabled && isRedirectStatus) {
250249

251250
if (future.incrementAndGetCurrentRedirectCount() < config.getMaxRedirects()) {
@@ -262,7 +261,7 @@ private boolean redirect(Request request, NettyResponseFuture<?> future, HttpRes
262261
}
263262

264263
// FIXME why not do that for 301 and 307 too?
265-
if ((status == FOUND || status == SEE_OTHER) && !(status == FOUND && config.isStrict302Handling())) {
264+
if ((status.equals(FOUND) || status.equals(SEE_OTHER)) && !(status.equals(FOUND) && config.isStrict302Handling())) {
266265
nBuilder.setMethod(HttpMethod.GET.name());
267266
}
268267

@@ -757,7 +756,7 @@ public void handle(ChannelHandlerContext ctx, NettyResponseFuture future, Object
757756
if (redirect(request, future, response, ctx))
758757
return;
759758

760-
boolean validStatus = response.getStatus() == SWITCHING_PROTOCOLS;
759+
boolean validStatus = response.getStatus().equals(SWITCHING_PROTOCOLS);
761760
boolean validUpgrade = response.headers().get(HttpHeaders.Names.UPGRADE) != null;
762761
String c = response.headers().get(HttpHeaders.Names.CONNECTION);
763762
if (c == null) {

0 commit comments

Comments
 (0)