Modifier and Type | Field and Description |
---|---|
protected Integer |
connectTimeout |
protected com.splunk.SimpleCookieStore |
cookieStore |
protected Map<String,String> |
customHeaders |
protected String |
host
The host name of the service.
|
protected URLStreamHandler |
httpsHandler
A variable to hold an optional custom HTTPS handler
|
protected int |
port
The port number of the service.
|
protected Integer |
readTimeout |
protected String |
scheme
The scheme used to access the service.
|
protected static SSLSecurityProtocol |
sslSecurityProtocol |
protected static boolean |
validateCertificates
Boolean flag for validating certificates at either of the sides (client/server).
|
Constructor and Description |
---|
HttpService()
Constructs a new
HttpService instance. |
HttpService(String host)
Constructs a new
HttpService instance at the given host. |
HttpService(String host,
int port)
Constructs a new
HttpService instance at the given host and port. |
HttpService(String host,
int port,
String scheme)
Constructs a new
HttpService instance using the given host,
port, and scheme. |
HttpService(String host,
int port,
String scheme,
URLStreamHandler httpsHandler)
Constructs a new
HttpService instance using the given host,
port, and scheme, and instructing it to use the specified HTTPS handler. |
Modifier and Type | Method and Description |
---|---|
void |
addCookie(String setCookieHeader)
Adds the passed cookie header to the cookieStore
|
static SSLSocketFactory |
createSSLFactory() |
ResponseMessage |
delete(String path)
Issues a DELETE request against the service using a given path.
|
ResponseMessage |
delete(String path,
Map<String,Object> args)
Issues a DELETE request against the service using a given path
and query arguments.
|
ResponseMessage |
get(String path)
Issues an HTTP GET request against the service using a given path.
|
ResponseMessage |
get(String path,
Map<String,Object> args)
Issues an HTTP GET request against the service using a given path and
query arguments.
|
Integer |
getConnectTimeout()
Returns the connect timeout used by this service.
|
Map<String,String> |
getCustomHeaders()
Returns all the stored custom headers
|
String |
getHost()
Returns the host name of this service.
|
int |
getPort()
Returns the port number of this service.
|
String |
getPrefix()
Returns the URL prefix of this service, consisting of
scheme://host[:port] . |
Integer |
getReadTimeout()
Returns the read timeout used by this service.
|
String |
getScheme()
Returns the scheme used by this service.
|
static SSLSecurityProtocol |
getSslSecurityProtocol()
Returns the SSL security protocol of this service.
|
static SSLSocketFactory |
getSSLSocketFactory() |
URL |
getUrl(String path)
Constructs a fully-qualified URL for this service using a given path.
|
Boolean |
hasSplunkAuthCookies()
Returns true if the cookieStore has any Splunk Authorization cookies, false otherwise
|
ResponseMessage |
post(String path)
Issues a POST request against the service using a given path.
|
ResponseMessage |
post(String path,
Map<String,Object> args)
Issues a POST request against the service using a given path and
form arguments.
|
void |
removeAllCookies()
Removes all cookies from the cookieStore
|
ResponseMessage |
send(String path,
RequestMessage request)
Issue an HTTP request against the service using a given path and
request message.
|
void |
setConnectTimeout(Integer connectTimeout)
Sets a specified timeout value, in milliseconds, to be used when opening a communications link.
|
void |
setCustomHeaders(Map<String,String> headers)
Sets Custom Headers of this service
|
void |
setReadTimeout(Integer readTimeout)
Sets a specified timeout value, in milliseconds, to be used when reading from a communications link.
|
static void |
setSslSecurityProtocol(SSLSecurityProtocol securityProtocol)
Sets the SSL security protocol of this service.
|
static void |
setSSLSocketFactory(SSLSocketFactory sslSocketFactory) |
static void |
setValidateCertificates(boolean validateCertificates) |
String |
stringifyCookies()
Returns all the stored cookies
|
protected static SSLSecurityProtocol sslSecurityProtocol
protected static boolean validateCertificates
protected URLStreamHandler httpsHandler
protected String scheme
protected String host
protected int port
protected Integer connectTimeout
protected Integer readTimeout
protected com.splunk.SimpleCookieStore cookieStore
public HttpService()
HttpService
instance.public HttpService(String host)
HttpService
instance at the given host.host
- The host name of the service.public HttpService(String host, int port)
HttpService
instance at the given host and port.host
- The host name of the service.port
- The port number of the service.public HttpService(String host, int port, String scheme)
HttpService
instance using the given host,
port, and scheme.host
- The host name of the service.port
- The port number of the service.scheme
- Scheme for accessing the service (http
or
https
).public HttpService(String host, int port, String scheme, URLStreamHandler httpsHandler)
HttpService
instance using the given host,
port, and scheme, and instructing it to use the specified HTTPS handler.host
- The host name of the service.port
- The port number of the service.scheme
- Scheme for accessing the service (http
or
https
).httpsHandler
- A custom URL Stream handler.public ResponseMessage get(String path)
path
- The request path.public ResponseMessage get(String path, Map<String,Object> args)
path
- The request path.args
- The query arguments.public String getHost()
public int getPort()
public void setCustomHeaders(Map<String,String> headers)
headers
- The custom headers.public static SSLSecurityProtocol getSslSecurityProtocol()
public static void setSslSecurityProtocol(SSLSecurityProtocol securityProtocol)
securityProtocol
- The SSLSecurityProtocal instancepublic String getPrefix()
scheme://host[:port]
.public String getScheme()
public URL getUrl(String path)
path
- The path to qualify.public Map<String,String> getCustomHeaders()
public String stringifyCookies()
public void addCookie(String setCookieHeader)
setCookieHeader
- The result from a getRequestHeader("Set-Cookie") callpublic void removeAllCookies()
public Boolean hasSplunkAuthCookies()
public Integer getConnectTimeout()
public void setConnectTimeout(Integer connectTimeout)
connectTimeout
- timeout in milliseconds, a timeout of zero is interpreted as an infinite timeout.public Integer getReadTimeout()
public void setReadTimeout(Integer readTimeout)
readTimeout
- timeout in milliseconds, a timeout of zero is interpreted as an infinite timeout.public ResponseMessage post(String path)
path
- The request path.public ResponseMessage post(String path, Map<String,Object> args)
path
- The request path.args
- The form arguments.public ResponseMessage delete(String path)
path
- The request path.public ResponseMessage delete(String path, Map<String,Object> args)
path
- The request path.args
- The query arguments.public ResponseMessage send(String path, RequestMessage request)
path
- The request path.request
- The request message.public static void setSSLSocketFactory(SSLSocketFactory sslSocketFactory)
public static SSLSocketFactory getSSLSocketFactory()
public static void setValidateCertificates(boolean validateCertificates)
public static SSLSocketFactory createSSLFactory()
Copyright © 2022 Splunk, Inc.. All rights reserved.