public class UtilHttpClientOneShot extends Object
HttpHost httpHost = new HttpHost("localhost", 9200);
String result = new HttpClient()
.put(httpHost, "/_template/mapping_metric", "your mapping");
Constructor and Description |
---|
UtilHttpClientOneShot()
Ctor.
|
UtilHttpClientOneShot(int timeoutMs)
Ctor
|
Modifier and Type | Method and Description |
---|---|
String |
get(org.apache.http.HttpHost[] hosts,
String request,
ISettingsMap credentials)
Perform the GET request, trying each server from the list in turn
|
String |
get(org.apache.http.HttpHost host,
String request,
ISettingsMap credentials)
Connect to the server, perform the request, close the connection to the server and send back the result
|
String |
post(org.apache.http.HttpHost[] hosts,
String request,
String form)
Connect to the servers, perform the request, close the connection to the server and send back the result
|
String |
post(org.apache.http.HttpHost hosts,
String request,
String form)
Connect to the server, perform the request, close the connection to the server and send back the result
|
String |
put(org.apache.http.HttpHost[] hosts,
String request,
String form)
Connect to the servers, perform the request, close the connection to the server and send back the result
|
String |
put(org.apache.http.HttpHost host,
String request,
String body)
Connect to the server, perform the PUT request, close the connection to the server and send back the result
|
void |
setHeaders(Map<String,String> headers) |
UtilHttpClientOneShot |
setTimeout(int timeoutMs)
Timeout setter
|
public UtilHttpClientOneShot(int timeoutMs)
timeoutMs
- the connection and request timeout in millisecondpublic UtilHttpClientOneShot()
public UtilHttpClientOneShot setTimeout(int timeoutMs)
timeoutMs
- the connection and request timeout in millisecondspublic String get(org.apache.http.HttpHost host, String request, ISettingsMap credentials) throws IOException
host
- the target hostrequest
- the requestcredentials
- credentials of the requestIOException
- in case of connection or request execution problempublic String get(org.apache.http.HttpHost[] hosts, String request, ISettingsMap credentials) throws IOException
hosts
- the target servers urlrequest
- the requestcredentials
- credentials of the requestIOException
- in case of connection or request execution problempublic String post(org.apache.http.HttpHost[] hosts, String request, String form) throws IOException
hosts
- the target hosts, the first one available will be pickedrequest
- the requestform
- form to postIOException
- in case of connection or request execution problempublic String post(org.apache.http.HttpHost hosts, String request, String form) throws IOException
hosts
- the target server urlrequest
- the requestform
- form to postIOException
- in case of connection or request execution problempublic String put(org.apache.http.HttpHost[] hosts, String request, String form) throws IOException
hosts
- the target hosts, the first one available will be pickedrequest
- the requestform
- form to postIOException
- in case of connection or request execution problempublic String put(org.apache.http.HttpHost host, String request, String body) throws org.apache.http.client.ClientProtocolException, IOException
host
- the target server urlrequest
- the requestbody
- your put body
form to postorg.apache.http.client.ClientProtocolException
- in case of http protocol errorIOException
- in case of connection or request execution problemCopyright © 2014–2023. All rights reserved.