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  int port
          The port number of the service.
protected  java.lang.String scheme
          The scheme used to access the service.
 
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.
 
Method Summary
 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.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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).
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.

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.