17
17
18
18
package org .openqa .selenium .netty .server ;
19
19
20
+ import static io .netty .handler .codec .http .HttpMethod .DELETE ;
21
+ import static io .netty .handler .codec .http .HttpMethod .GET ;
20
22
import static io .netty .handler .codec .http .HttpMethod .HEAD ;
23
+ import static io .netty .handler .codec .http .HttpMethod .OPTIONS ;
24
+ import static io .netty .handler .codec .http .HttpMethod .POST ;
21
25
import static org .openqa .selenium .remote .http .Contents .memoize ;
22
26
23
27
import com .google .common .io .ByteStreams ;
47
51
import java .io .PipedInputStream ;
48
52
import java .io .PipedOutputStream ;
49
53
import java .io .UncheckedIOException ;
54
+ import java .util .Arrays ;
55
+ import java .util .List ;
50
56
import java .util .concurrent .ExecutorService ;
51
57
import java .util .concurrent .Executors ;
52
58
import java .util .logging .Logger ;
@@ -56,6 +62,8 @@ class RequestConverter extends SimpleChannelInboundHandler<HttpObject> {
56
62
private static final Logger LOG = Logger .getLogger (RequestConverter .class .getName ());
57
63
private static final ExecutorService EXECUTOR = Executors .newSingleThreadExecutor ();
58
64
private volatile PipedOutputStream out ;
65
+ private static final List <io .netty .handler .codec .http .HttpMethod > supportedMethods =
66
+ Arrays .asList (DELETE , GET , POST , OPTIONS );
59
67
60
68
@ Override
61
69
protected void channelRead0 (
@@ -132,14 +140,18 @@ private HttpRequest createRequest(
132
140
HttpMethod method ;
133
141
if (nettyRequest .method ().equals (HEAD )) {
134
142
method = HttpMethod .GET ;
135
- } else {
143
+ } else if ( supportedMethods . contains ( nettyRequest . method ())) {
136
144
try {
137
145
method = HttpMethod .valueOf (nettyRequest .method ().name ());
138
146
} catch (IllegalArgumentException e ) {
139
147
ctx .writeAndFlush (
140
148
new DefaultFullHttpResponse (HttpVersion .HTTP_1_1 , HttpResponseStatus .METHOD_NOT_ALLOWED ));
141
149
return null ;
142
150
}
151
+ } else {
152
+ ctx .writeAndFlush (
153
+ new DefaultFullHttpResponse (HttpVersion .HTTP_1_1 , HttpResponseStatus .METHOD_NOT_ALLOWED ));
154
+ return null ;
143
155
}
144
156
145
157
// Attempt to decode parameters
0 commit comments