1717
1818package org .openqa .selenium .netty .server ;
1919
20+ import static io .netty .handler .codec .http .HttpMethod .DELETE ;
21+ import static io .netty .handler .codec .http .HttpMethod .GET ;
2022import 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 ;
2125import static org .openqa .selenium .remote .http .Contents .memoize ;
2226
2327import com .google .common .io .ByteStreams ;
4751import java .io .PipedInputStream ;
4852import java .io .PipedOutputStream ;
4953import java .io .UncheckedIOException ;
54+ import java .util .Arrays ;
55+ import java .util .List ;
5056import java .util .concurrent .ExecutorService ;
5157import java .util .concurrent .Executors ;
5258import java .util .logging .Logger ;
@@ -56,6 +62,8 @@ class RequestConverter extends SimpleChannelInboundHandler<HttpObject> {
5662 private static final Logger LOG = Logger .getLogger (RequestConverter .class .getName ());
5763 private static final ExecutorService EXECUTOR = Executors .newSingleThreadExecutor ();
5864 private volatile PipedOutputStream out ;
65+ private static final List <io .netty .handler .codec .http .HttpMethod > supportedMethods =
66+ Arrays .asList (DELETE , GET , POST , OPTIONS );
5967
6068 @ Override
6169 protected void channelRead0 (
@@ -132,14 +140,18 @@ private HttpRequest createRequest(
132140 HttpMethod method ;
133141 if (nettyRequest .method ().equals (HEAD )) {
134142 method = HttpMethod .GET ;
135- } else {
143+ } else if ( supportedMethods . contains ( nettyRequest . method ())) {
136144 try {
137145 method = HttpMethod .valueOf (nettyRequest .method ().name ());
138146 } catch (IllegalArgumentException e ) {
139147 ctx .writeAndFlush (
140148 new DefaultFullHttpResponse (HttpVersion .HTTP_1_1 , HttpResponseStatus .METHOD_NOT_ALLOWED ));
141149 return null ;
142150 }
151+ } else {
152+ ctx .writeAndFlush (
153+ new DefaultFullHttpResponse (HttpVersion .HTTP_1_1 , HttpResponseStatus .METHOD_NOT_ALLOWED ));
154+ return null ;
143155 }
144156
145157 // Attempt to decode parameters
0 commit comments