support missing OPTIONS method, it is supported in elasticsearch core

This commit is contained in:
javanna 2016-05-18 13:52:33 +02:00 committed by Luca Cavanna
parent 9a38d81bec
commit 6d3f6c7faf
1 changed files with 6 additions and 0 deletions

View File

@ -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);