8000 Drop UPGRADE State, close #1347 · chakra-coder/async-http-client@916b8aa · GitHub
[go: up one dir, main page]

Skip to content

Commit 916b8aa

Browse files
committed
Drop UPGRADE State, close AsyncHttpClient#1347
Motivation: The UPGRADE State is only returned by `WebSocketUpgradeHandler:: onStatusReceived` which is internal and that can only return 2 values, so it could return CONTINUE instead. Modifications: * Drop UPGRADE * Use CONTINUE instead Result: More simple code
1 parent 97bc355 commit 916b8aa

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ enum State {
5858
/**
5959
* Continue the processing
6060
*/
61-
CONTINUE,
62-
/**
63-
* Upgrade the protocol.
64-
*/
65-
UPGRADE
61+
CONTINUE
6662
}
6763

6864
/**

client/src/main/java/org/asynchttpclient/netty/handler/WebSocketHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void call() throws Exception {
9090
if (connection == null)
9191
connection = response.headers().get(CONNECTION);
9292
boolean validConnection = HttpHeaderValues.UPGRADE.contentEqualsIgnoreCase(connection);
93-
boolean statusReceived = handler.onStatusReceived(status) == State.UPGRADE;
93+
boolean statusReceived = handler.onStatusReceived(status) == State.CONTINUE;
9494

9595
if (!statusReceived) {
9696
try {

client/src/main/java/org/asynchttpclient/ws/WebSocketUpgradeHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public final State onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exce
6767
@Override
6868
public final State onStatusReceived(HttpResponseStatus responseStatus) throws Exception {
6969
status = responseStatus.getStatusCode();
70-
return status == SWITCHING_PROTOCOLS ? State.UPGRADE : State.ABORT;
70+
return status == SWITCHING_PROTOCOLS ? State.CONTINUE : State.ABORT;
7171
}
7272

7373
@Override

0 commit comments

Comments
 (0)
0