Add TRACE, CONNECT, and PATCH http methods (#31035)

This is related to #31017. That issue identified that these three http
methods were treated like GET requests. This commit adds them to
RestRequest. This means that these methods will be handled properly and
generate 405s.
This commit is contained in:
Tim Brooks 2018-06-01 17:07:54 -06:00 committed by GitHub
parent 2401150be7
commit f8785dda9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 3 deletions

View File

@ -119,7 +119,19 @@ public class Netty4HttpRequest extends RestRequest {
return Method.OPTIONS;
}
return Method.GET;
if (httpMethod == HttpMethod.PATCH) {
return Method.PATCH;
}
if (httpMethod == HttpMethod.TRACE) {
return Method.TRACE;
}
if (httpMethod == HttpMethod.CONNECT) {
return Method.CONNECT;
}
throw new IllegalArgumentException("Unexpected http method: " + httpMethod);
}
@Override

View File

@ -84,7 +84,19 @@ public class NioHttpRequest extends RestRequest {
return Method.OPTIONS;
}
return Method.GET;
if (httpMethod == HttpMethod.PATCH) {
return Method.PATCH;
}
if (httpMethod == HttpMethod.TRACE) {
return Method.TRACE;
}
if (httpMethod == HttpMethod.CONNECT) {
return Method.CONNECT;
}
throw new IllegalArgumentException("Unexpected http method: " + httpMethod);
}
@Override

View File

@ -130,7 +130,7 @@ public abstract class RestRequest implements ToXContent.Params {
}
public enum Method {
GET, POST, PUT, DELETE, OPTIONS, HEAD
GET, POST, PUT, DELETE, OPTIONS, HEAD, PATCH, TRACE, CONNECT
}
public abstract Method method();