GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Compare HttpMethod by reference (#8815) · netty/netty@ff74848

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • codec-http/src/main/java/io/netty/handler/codec
    • http
      • HttpContentEncoder.java
      • HttpMethod.java
      • HttpServerCodec.java
      • cors
        • CorsHandler.java
      • websocketx
        • WebSocketServerProtocolHandshakeHandler.java
    • rtsp
      • RtspMethods.java
  • example/src/main/java/io/netty/example/http
    • file
      • HttpStaticFileServerHandler.java
    • upload
      • HttpUploadServerHandler.java
    • websocketx
      • benchmarkserver
        • WebSocketServerHandler.java
      • server
        • WebSocketIndexPageHandler.java
  • testsuite-autobahn/src/main/java/io/netty/testsuite/autobahn
    • AutobahnServerHandler.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎codec-http/src/main/java/io/netty/handler/codec/http/HttpContentEncoder.java‎

Copy file name to clipboardExpand all lines: codec-http/src/main/java/io/netty/handler/codec/http/HttpContentEncoder.java
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ protected void decode(ChannelHandlerContext ctx, HttpRequest msg, List<Object> o
7878
acceptedEncoding = HttpContentDecoder.IDENTITY;
7979
}
8080

81-
HttpMethod meth = msg.method();
82-
if (meth == HttpMethod.HEAD) {
81+
HttpMethod method = msg.method();
82+
if (HttpMethod.HEAD.equals(method)) {
8383
acceptedEncoding = ZERO_LENGTH_HEAD;
84-
} else if (meth == HttpMethod.CONNECT) {
84+
} else if (HttpMethod.CONNECT.equals(method)) {
8585
acceptedEncoding = ZERO_LENGTH_CONNECT;
8686
}
8787

Collapse file

‎codec-http/src/main/java/io/netty/handler/codec/http/HttpMethod.java‎

Copy file name to clipboardExpand all lines: codec-http/src/main/java/io/netty/handler/codec/http/HttpMethod.java
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ public int hashCode() {
156156

157157
@Override
158158
public boolean equals(Object o) {
159+
if (this == o) {
160+
return true;
161+
}
159162
if (!(o instanceof HttpMethod)) {
160163
return false;
161164
}
@@ -171,6 +174,9 @@ public String toString() {
171174

172175
@Override
173176
public int compareTo(HttpMethod o) {
177+
if (o == this) {
178+
return 0;
179+
}
174180
return name().compareTo(o.name());
175181
}
176182

Collapse file

‎codec-http/src/main/java/io/netty/handler/codec/http/HttpServerCodec.java‎

Copy file name to clipboardExpand all lines: codec-http/src/main/java/io/netty/handler/codec/http/HttpServerCodec.java
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ private final class HttpServerResponseEncoder extends HttpResponseEncoder {
117117

118118
@Override
119119
protected void sanitizeHeadersBeforeEncode(HttpResponse msg, boolean isAlwaysEmpty) {
120-
if (!isAlwaysEmpty && method == HttpMethod.CONNECT && msg.status().codeClass() == HttpStatusClass.SUCCESS) {
120+
if (!isAlwaysEmpty && HttpMethod.CONNECT.equals(method)
121+
&& msg.status().codeClass() == HttpStatusClass.SUCCESS) {
121122
// Stripping Transfer-Encoding:
122123
// See https://tools.ietf.org/html/rfc7230#section-3.3.1
123124
msg.headers().remove(HttpHeaderNames.TRANSFER_ENCODING);
Collapse file

‎codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsHandler.java‎

Copy file name to clipboardExpand all lines: codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsHandler.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ private void setAllowCredentials(final HttpResponse response) {
191191

192192
private static boolean isPreflightRequest(final HttpRequest request) {
193193
final HttpHeaders headers = request.headers();
194-
return request.method().equals(OPTIONS) &&
194+
return OPTIONS.equals(request.method()) &&
195195
headers.contains(HttpHeaderNames.ORIGIN) &&
196196
headers.contains(HttpHeaderNames.ACCESS_CONTROL_REQUEST_METHOD);
197197
}
Collapse file

‎codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java‎

Copy file name to clipboardExpand all lines: codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void channelRead(final ChannelHandlerContext ctx, Object msg) throws Exce
6868
}
6969

7070
try {
71-
if (req.method() != GET) {
71+
if (!GET.equals(req.method())) {
7272
sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN));
7373
return;
7474
}
Collapse file

‎codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspMethods.java‎

Copy file name to clipboardExpand all lines: codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspMethods.java
+11-11Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,62 +38,62 @@ public final class RtspMethods {
3838
* The DESCRIBE getMethod retrieves the description of a presentation or
3939
* media object identified by the request URL from a server.
4040
*/
41-
public static final HttpMethod DESCRIBE = new HttpMethod("DESCRIBE");
41+
public static final HttpMethod DESCRIBE = HttpMethod.valueOf("DESCRIBE");
4242

4343
/**
4444
* The ANNOUNCE posts the description of a presentation or media object
4545
* identified by the request URL to a server, or updates the client-side
4646
* session description in real-time.
4747
*/
48-
public static final HttpMethod ANNOUNCE = new HttpMethod("ANNOUNCE");
48+
public static final HttpMethod ANNOUNCE = HttpMethod.valueOf("ANNOUNCE");
4949

5050
/**
5151
* The SETUP request for a URI specifies the transport mechanism to be
5252
* used for the streamed media.
5353
*/
54-
public static final HttpMethod SETUP = new HttpMethod("SETUP");
54+
public static final HttpMethod SETUP = HttpMethod.valueOf("SETUP");
5555

5656
/**
5757
* The PLAY getMethod tells the server to start sending data via the
5858
* mechanism specified in SETUP.
5959
*/
60-
public static final HttpMethod PLAY = new HttpMethod("PLAY");
60+
public static final HttpMethod PLAY = HttpMethod.valueOf("PLAY");
6161

6262
/**
6363
* The PAUSE request causes the stream delivery to be interrupted
6464
* (halted) temporarily.
6565
*/
66-
public static final HttpMethod PAUSE = new HttpMethod("PAUSE");
66+
public static final HttpMethod PAUSE = HttpMethod.valueOf("PAUSE");
6767

6868
/**
6969
* The TEARDOWN request stops the stream delivery for the given URI,
7070
* freeing the resources associated with it.
7171
*/
72-
public static final HttpMethod TEARDOWN = new HttpMethod("TEARDOWN");
72+
public static final HttpMethod TEARDOWN = HttpMethod.valueOf("TEARDOWN");
7373

7474
/**
7575
* The GET_PARAMETER request retrieves the value of a parameter of a
7676
* presentation or stream specified in the URI.
7777
*/
78-
public static final HttpMethod GET_PARAMETER = new HttpMethod("GET_PARAMETER");
78+
public static final HttpMethod GET_PARAMETER = HttpMethod.valueOf("GET_PARAMETER");
7979

8080
/**
8181
* The SET_PARAMETER requests to set the value of a parameter for a
8282
* presentation or stream specified by the URI.
8383
*/
84-
public static final HttpMethod SET_PARAMETER = new HttpMethod("SET_PARAMETER");
84+
public static final HttpMethod SET_PARAMETER = HttpMethod.valueOf("SET_PARAMETER");
8585

8686
/**
8787
* The REDIRECT request informs the client that it must connect to another
8888
* server location.
8989
*/
90-
public static final HttpMethod REDIRECT = new HttpMethod("REDIRECT");
90+
public static final HttpMethod REDIRECT = HttpMethod.valueOf("REDIRECT");
9191

9292
/**
9393
* The RECORD getMethod initiates recording a range of media data according to
9494
* the presentation description.
9595
*/
96-
public static final HttpMethod RECORD = new HttpMethod("RECORD");
96+
public static final HttpMethod RECORD = HttpMethod.valueOf("RECORD");
9797

9898
private static final Map<String, HttpMethod> methodMap = new HashMap<String, HttpMethod>();
9999

@@ -130,7 +130,7 @@ public static HttpMethod valueOf(String name) {
130130
if (result != null) {
131131
return result;
132132
} else {
133-
return new HttpMethod(name);
133+
return HttpMethod.valueOf(name);
134134
}
135135
}
136136

Collapse file

‎example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java‎

Copy file name to clipboardExpand all lines: example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) thr
117117
return;
118118
}
119119

120-
if (request.method() != GET) {
120+
if (!GET.equals(request.method())) {
121121
sendError(ctx, METHOD_NOT_ALLOWED);
122122
return;
123123
}
Collapse file

‎example/src/main/java/io/netty/example/http/upload/HttpUploadServerHandler.java‎

Copy file name to clipboardExpand all lines: example/src/main/java/io/netty/example/http/upload/HttpUploadServerHandler.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Excep
145145
responseContent.append("\r\n\r\n");
146146

147147
// if GET Method: should not try to create a HttpPostRequestDecoder
148-
if (request.method().equals(HttpMethod.GET)) {
148+
if (HttpMethod.GET.equals(request.method())) {
149149
// GET Method: should not try to create a HttpPostRequestDecoder
150150
// So stop here
151151
responseContent.append("\r\n\r\nEND OF GET CONTENT\r\n");
Collapse file

‎example/src/main/java/io/netty/example/http/websocketx/benchmarkserver/WebSocketServerHandler.java‎

Copy file name to clipboardExpand all lines: example/src/main/java/io/netty/example/http/websocketx/benchmarkserver/WebSocketServerHandler.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private void handleHttpRequest(ChannelHandlerContext ctx, FullHttpRequest req) {
7171
}
7272

7373
// Allow only GET methods.
74-
if (req.method() != GET) {
74+
if (!GET.equals(req.method())) {
7575
sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN));
7676
return;
7777
}
Collapse file

‎example/src/main/java/io/netty/example/http/websocketx/server/WebSocketIndexPageHandler.java‎

Copy file name to clipboardExpand all lines: example/src/main/java/io/netty/example/http/websocketx/server/WebSocketIndexPageHandler.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest req) thro
5858
}
5959

6060
// Allow only GET methods.
61-
if (req.method() != GET) {
61+
if (!GET.equals(req.method())) {
6262
sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN));
6363
return;
6464
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.