Use predefined HttpResponseStatus constant instead of hardcoded 101 code
Motivation: #7269 removed an unnecessary instanciation for verifying WebSocket handshake status code. But it uses a hardcoded status code value for 101 instead of using the intended `HttpResponseStatus#SWITCHING_PROTOCOLS` constant. Modidication: Compare actual `HttpResponseStatus` against predefined constant. Note that `HttpResponseStatus#equals` is implemented in respect with the RFC (only honor code, not text) so it’s intended to be used this way. Result: Cleaner code, use intended constant instead of hard coded value.
This commit is contained in:
parent
bb1833f22c
commit
940f15f0d2
@ -24,6 +24,7 @@ import io.netty.handler.codec.http.HttpHeaderNames;
|
||||
import io.netty.handler.codec.http.HttpHeaderValues;
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
import io.netty.handler.codec.http.HttpMethod;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.handler.codec.http.HttpVersion;
|
||||
import io.netty.util.AsciiString;
|
||||
|
||||
@ -177,7 +178,7 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
|
||||
*/
|
||||
@Override
|
||||
protected void verify(FullHttpResponse response) {
|
||||
if (response.status().code() != 101) {
|
||||
if (!response.status().equals(HttpResponseStatus.SWITCHING_PROTOCOLS)) {
|
||||
throw new WebSocketHandshakeException("Invalid handshake response getStatus: " + response.status());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user