public class UtilHttp extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
UtilHttp.Callback |
Constructor and Description |
---|
UtilHttp() |
Modifier and Type | Method and Description |
---|---|
static String |
applyPrefix(String host,
String prefix)
Apply a prefix for a host path
Eg :
http://host:port -> http://host:port/prefix
manage '/' char concatenation
|
static List<org.apache.http.HttpHost> |
applyScheme(List<org.apache.http.HttpHost> hosts,
String scheme)
Apply a scheme on all hosts in list
|
static org.apache.http.Header[] |
authenticate(String user,
String password,
String token,
String tokenType)
Add required headers for token authentication
|
static ISettingsMap |
getAuthenticationFromHeader(String header)
Parse an header to generate map containing all credentials information
(token type, token, username, password)
|
static String |
getBodyAsTextLines(String resourceUrl)
Fetch a remote HTTP resource.
|
static org.apache.http.HttpHost[] |
getHttpHosts(ISettingsList settingsList)
Takes as arguments a list of ISettingsMap where each of them contains two fields:
|
static List<org.apache.http.HttpHost> |
getHttpHosts(List<String> hosts) |
static List<org.apache.http.HttpHost> |
getHttpHosts(List<String> hosts,
String scheme)
Build a list of HttpHost from a string list of http hosts
The http host list can be :
- http://server1:9200
- http://server2:9201
If no scheme is provided with hosts like :
- server1:9200
- server2:9201
The default 'http' scheme is applied on each host
Providing a scheme in this method will only override hosts with no scheme yet.
|
static void |
getTextFileResourceByLine(String resourceUrl,
UtilHttp.Callback cb) |
static List<URI> |
getURIs(List<String> hosts) |
static List<URI> |
getURIs(List<String> hosts,
String scheme)
Build a list of URIs from a string list of http hosts
The http host list can be :
- http://server1:9200
- http://server2:9201
If no scheme is provided with hosts like :
- server1:9200
- server2:9201
The default 'http' scheme is applied on each host
Providing a scheme in this method will only override hosts with no scheme yet.
|
public static String getBodyAsTextLines(String resourceUrl) throws org.apache.http.client.ClientProtocolException, IOException
resourceUrl
- resource urlIOException
org.apache.http.client.ClientProtocolException
public static void getTextFileResourceByLine(String resourceUrl, UtilHttp.Callback cb) throws org.apache.http.client.ClientProtocolException, IOException
resourceUrl
- the target http resource urlcb
- IOException
org.apache.http.client.ClientProtocolException
public static org.apache.http.Header[] authenticate(String user, String password, String token, String tokenType)
user
- userpassword
- passwordtoken
- tokentokenType
- tokenTypepublic static ISettingsMap getAuthenticationFromHeader(String header)
header
- Header to parsepublic static org.apache.http.HttpHost[] getHttpHosts(ISettingsList settingsList)
- host - port
Host field is mandatory whereas port will default to 9200 if not set
settingsList
- public static List<URI> getURIs(List<String> hosts, String scheme) throws URISyntaxException
hosts
- String list of http hosts likescheme
- To apply on hosts without a schemeURISyntaxException
- if a host is malformedpublic static List<URI> getURIs(List<String> hosts) throws URISyntaxException
URISyntaxException
public static List<org.apache.http.HttpHost> getHttpHosts(List<String> hosts, String scheme) throws URISyntaxException
hosts
- String list of http hosts likescheme
- To apply on hosts without a schemeURISyntaxException
- if a host is malformedpublic static List<org.apache.http.HttpHost> getHttpHosts(List<String> hosts) throws URISyntaxException
URISyntaxException
public static List<org.apache.http.HttpHost> applyScheme(List<org.apache.http.HttpHost> hosts, String scheme)
hosts
- hosts listscheme
- scheme to apply on all hosts. MUST be 'http' or 'https'Copyright © 2014–2022. All rights reserved.