com.splunk
Class HttpService

java.lang.Object
  extended by com.splunk.HttpService
Direct Known Subclasses:
Service

public class HttpService
extends java.lang.Object

The HttpService class represents a generic HTTP service at a given address (host:port), accessed using a given protocol scheme (http or https).


Field Summary
protected  java.lang.String host
          The host name of the service.
protected  java.net.URLStreamHandler httpsHandler
          A variable to hold an optional custom HTTPS handler
protected  int port
          The port number of the service.
protected  java.lang.String scheme
          The scheme used to access the service.
protected static SSLSecurityProtocol sslSecurityProtocol
           
 
Constructor Summary
HttpService()
          Constructs a new HttpService instance.
HttpService(java.lang.String host)
          Constructs a new HttpService instance at the given host.
HttpService(java.lang.String host, int port)
          Constructs a new HttpService instance at the given host and port.
HttpService(java.lang.String host, int port, java.lang.String scheme)
          Constructs a new HttpService instance using the given host, port, and scheme.
HttpService(java.lang.String host, int port, java.lang.String scheme, java.net.URLStreamHandler httpsHandler)
          Constructs a new HttpService instance using the given host, port, and scheme, and instructing it to use the specified HTTPS handler.
 
Method Summary
static javax.net.ssl.SSLSocketFactory createSSLFactory()
           
 ResponseMessage delete(java.lang.String path)
          Issues a DELETE request against the service using a given path.
 ResponseMessage delete(java.lang.String path, java.util.Map<java.lang.String,java.lang.Object> args)
          Issues a DELETE request against the service using a given path and query arguments.
 ResponseMessage get(java.lang.String path)
          Issues an HTTP GET request against the service using a given path.
 ResponseMessage get(java.lang.String path, java.util.Map<java.lang.String,java.lang.Object> args)
          Issues an HTTP GET request against the service using a given path and query arguments.
 java.lang.String getHost()
          Returns the host name of this service.
 int getPort()
          Returns the port number of this service.
 java.lang.String getPrefix()
          Returns the URL prefix of this service, consisting of scheme://host[:port].
 java.lang.String getScheme()
          Returns the scheme used by this service.
static SSLSecurityProtocol getSslSecurityProtocol()
          Returns the SSL security protocol of this service.
static javax.net.ssl.SSLSocketFactory getSSLSocketFactory()
           
 java.net.URL getUrl(java.lang.String path)
          Constructs a fully-qualified URL for this service using a given path.
 ResponseMessage post(java.lang.String path)
          Issues a POST request against the service using a given path.
 ResponseMessage post(java.lang.String path, java.util.Map<java.lang.String,java.lang.Object> args)
          Issues a POST request against the service using a given path and form arguments.
 ResponseMessage send(java.lang.String path, RequestMessage request)
          Issue an HTTP request against the service using a given path and request message.
static void setSslSecurityProtocol(SSLSecurityProtocol securityProtocol)
          Sets the SSL security protocol of this service.
static void setSSLSocketFactory(javax.net.ssl.SSLSocketFactory sslSocketFactory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sslSecurityProtocol

protected static SSLSecurityProtocol sslSecurityProtocol

httpsHandler

protected java.net.URLStreamHandler httpsHandler
A variable to hold an optional custom HTTPS handler


scheme

protected java.lang.String scheme
The scheme used to access the service.


host

protected java.lang.String host
The host name of the service.


port

protected int port
The port number of the service.

Constructor Detail

HttpService

public HttpService()
Constructs a new HttpService instance.


HttpService

public HttpService(java.lang.String host)
Constructs a new HttpService instance at the given host.

Parameters:
host - The host name of the service.

HttpService

public HttpService(java.lang.String host,
                   int port)
Constructs a new HttpService instance at the given host and port.

Parameters:
host - The host name of the service.
port - The port number of the service.

HttpService

public HttpService(java.lang.String host,
                   int port,
                   java.lang.String scheme)
Constructs a new HttpService instance using the given host, port, and scheme.

Parameters:
host - The host name of the service.
port - The port number of the service.
scheme - Scheme for accessing the service (http or https).

HttpService

public HttpService(java.lang.String host,
                   int port,
                   java.lang.String scheme,
                   java.net.URLStreamHandler httpsHandler)
Constructs a new HttpService instance using the given host, port, and scheme, and instructing it to use the specified HTTPS handler.

Parameters:
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.
Method Detail

get

public ResponseMessage get(java.lang.String path)
Issues an HTTP GET request against the service using a given path.

Parameters:
path - The request path.
Returns:
The HTTP response.

get

public ResponseMessage get(java.lang.String path,
                           java.util.Map<java.lang.String,java.lang.Object> args)
Issues an HTTP GET request against the service using a given path and query arguments.

Parameters:
path - The request path.
args - The query arguments.
Returns:
The HTTP response.

getHost

public java.lang.String getHost()
Returns the host name of this service.

Returns:
The host name.

getPort

public int getPort()
Returns the port number of this service.

Returns:
The port number.

getSslSecurityProtocol

public static SSLSecurityProtocol getSslSecurityProtocol()
Returns the SSL security protocol of this service.

Returns:
The SSL security protocol.

setSslSecurityProtocol

public static void setSslSecurityProtocol(SSLSecurityProtocol securityProtocol)
Sets the SSL security protocol of this service.


getPrefix

public java.lang.String getPrefix()
Returns the URL prefix of this service, consisting of scheme://host[:port].

Returns:
The URL prefix.

getScheme

public java.lang.String getScheme()
Returns the scheme used by this service.

Returns:
The scheme.

getUrl

public java.net.URL getUrl(java.lang.String path)
Constructs a fully-qualified URL for this service using a given path.

Parameters:
path - The path to qualify.
Returns:
The fully-qualified URL for the service.

post

public ResponseMessage post(java.lang.String path)
Issues a POST request against the service using a given path.

Parameters:
path - The request path.
Returns:
The HTTP response.

post

public ResponseMessage post(java.lang.String path,
                            java.util.Map<java.lang.String,java.lang.Object> args)
Issues a POST request against the service using a given path and form arguments.

Parameters:
path - The request path.
args - The form arguments.
Returns:
The HTTP response.

delete

public ResponseMessage delete(java.lang.String path)
Issues a DELETE request against the service using a given path.

Parameters:
path - The request path.
Returns:
The HTTP response.

delete

public ResponseMessage delete(java.lang.String path,
                              java.util.Map<java.lang.String,java.lang.Object> args)
Issues a DELETE request against the service using a given path and query arguments.

Parameters:
path - The request path.
args - The query arguments.
Returns:
The HTTP response.

send

public ResponseMessage send(java.lang.String path,
                            RequestMessage request)
Issue an HTTP request against the service using a given path and request message.

Parameters:
path - The request path.
request - The request message.
Returns:
The HTTP response.

setSSLSocketFactory

public static void setSSLSocketFactory(javax.net.ssl.SSLSocketFactory sslSocketFactory)

getSSLSocketFactory

public static javax.net.ssl.SSLSocketFactory getSSLSocketFactory()

createSSLFactory

public static javax.net.ssl.SSLSocketFactory createSSLFactory()