Skip to content

Commit 75f73ff

Browse files
u2032slandelle
authored andcommitted
Support of 308 HTTP Status (AsyncHttpClient#1438)
Motivation: The status 308 is defined by RFC7538. This RFC has currently the state Proposed Standard since 2 years, but the status code is already handle by all browsers (Chrome, Firefox, Edge, Safari, …). Changes: HTTP Status 308 is added to constants HTTP Status 308 is added on well-known status for redirection When 308, according to the RFC, we are not allowed to switch to get and we keep body
1 parent af2cfea commit 75f73ff

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

client/src/main/java/org/asynchttpclient/netty/handler/intercept/Redirect30xInterceptor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public class Redirect30xInterceptor {
5050
REDIRECT_STATUSES.add(FOUND_302);
5151
REDIRECT_STATUSES.add(SEE_OTHER_303);
5252
REDIRECT_STATUSES.add(TEMPORARY_REDIRECT_307);
53+
REDIRECT_STATUSES.add(PERMANENT_REDIRECT_308);
5354
}
5455

5556
private static final Logger LOGGER = LoggerFactory.getLogger(Redirect30xInterceptor.class);
@@ -87,7 +88,7 @@ public boolean exitAfterHandlingRedirect(//
8788
String originalMethod = request.getMethod();
8889
boolean switchToGet = !originalMethod.equals(GET)
8990
&& (statusCode == MOVED_PERMANENTLY_301 || statusCode == SEE_OTHER_303 || (statusCode == FOUND_302 && !config.isStrict302Handling()));
90-
boolean keepBody = statusCode == TEMPORARY_REDIRECT_307 || (statusCode == FOUND_302 && config.isStrict302Handling());
91+
boolean keepBody = statusCode == TEMPORARY_REDIRECT_307 || statusCode == PERMANENT_REDIRECT_308 || (statusCode == FOUND_302 && config.isStrict302Handling());
9192

9293
final RequestBuilder requestBuilder = new RequestBuilder(switchToGet ? GET : originalMethod)//
9394
.setCookies(request.getCookies())//

client/src/main/java/org/asynchttpclient/util/HttpConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public static final class ResponseStatusCodes {
4242
public static final int SEE_OTHER_303 = HttpResponseStatus.SEE_OTHER.code();
4343
public static final int NOT_MODIFIED_304 = HttpResponseStatus.NOT_MODIFIED.code();
4444
public static final int TEMPORARY_REDIRECT_307 = HttpResponseStatus.TEMPORARY_REDIRECT.code();
45+
public static final int PERMANENT_REDIRECT_308 = HttpResponseStatus.PERMANENT_REDIRECT.code();
4546
public static final int UNAUTHORIZED_401 = HttpResponseStatus.UNAUTHORIZED.code();
4647
public static final int PROXY_AUTHENTICATION_REQUIRED_407 = HttpResponseStatus.PROXY_AUTHENTICATION_REQUIRED.code();
4748

0 commit comments

Comments
 (0)