Skip to content

Commit

Permalink
Add TRACE, CONNECT, and PATCH http methods (elastic#31035)
Browse files Browse the repository at this point in the history
This is related to elastic#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.
  • Loading branch information
Tim-Brooks authored Jun 1, 2018
1 parent 2401150 commit f8785dd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,19 @@ public Method method() {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,19 @@ public Method method() {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public RestRequest(
}

public enum Method {
GET, POST, PUT, DELETE, OPTIONS, HEAD
GET, POST, PUT, DELETE, OPTIONS, HEAD, PATCH, TRACE, CONNECT
}

public abstract Method method();
Expand Down

0 comments on commit f8785dd

Please sign in to comment.