Remove unnecessary instantiation of HttpResponseStatus

Motivation:
- In the `HttpResponseStatus#equals` checks only status code. No need to create new instance of `HttpResponseStatus` for comparison with response status.
- The RFC says: `the HTTP version and reason phrase aren't important` [1].

Modifications:
Use comparison by status code without creating new `HttpResponseStatus`.

Result:
Less allocations, more clear code.

[1] https://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-00
This commit is contained in:
Nikolay Fedorovskikh 2017-10-01 00:59:26 +05:00 committed by Norman Maurer
parent 47f016bf56
commit 78786e6052

View File

@ -24,7 +24,6 @@ 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;
@ -178,9 +177,7 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
*/
@Override
protected void verify(FullHttpResponse response) {
final HttpResponseStatus status = new HttpResponseStatus(101, "WebSocket Protocol Handshake");
if (!response.status().equals(status)) {
if (response.status().code() != 101) {
throw new WebSocketHandshakeException("Invalid handshake response getStatus: " + response.status());
}