diff --git a/client/src/main/java/org/elasticsearch/client/RestClient.java b/client/src/main/java/org/elasticsearch/client/RestClient.java index 4e414033d4a..6c37fd58ae1 100644 --- a/client/src/main/java/org/elasticsearch/client/RestClient.java +++ b/client/src/main/java/org/elasticsearch/client/RestClient.java @@ -27,6 +27,7 @@ import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; import org.apache.http.client.methods.HttpHead; +import org.apache.http.client.methods.HttpOptions; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPut; import org.apache.http.client.methods.HttpRequestBase; @@ -229,6 +230,11 @@ public final class RestClient implements Closeable { throw new UnsupportedOperationException("HEAD with body is not supported"); } return new HttpHead(uri); + case HttpOptions.METHOD_NAME: + if (entity != null) { + throw new UnsupportedOperationException("OPTIONS with body is not supported"); + } + return new HttpOptions(uri); case HttpPost.METHOD_NAME: HttpPost httpPost = new HttpPost(uri); addRequestBody(httpPost, entity);