public class Http
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Http.AuthRequiredException
Exception signifying that an http request failed with a WWW-Authenticate response
|
static interface |
Http.BodyHandler<T>
Interface for an entity that performs type-specific processing on an http response body
|
static class |
Http.ByteArrayRequestBody
A RequestBody wrapping a byte array
|
static class |
Http.FormRequestBody |
static class |
Http.JsonRequestBody
A RequestBody wrapping a JSON-serialisable object
|
static interface |
Http.RequestBody
Interface for an entity that supplies an http request body
|
static class |
Http.Response
A type encapsulating an http response
|
static interface |
Http.ResponseHandler<T>
Interface for an entity that performs type-specific processing on an http response
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DELETE |
static java.lang.String |
GET |
static java.lang.String |
POST |
static java.lang.String |
PUT |
| Constructor and Description |
|---|
Http(ClientOptions options,
Auth auth)
Public API
|
| Modifier and Type | Method and Description |
|---|---|
<T> T |
ablyHttpExecute(java.lang.String path,
java.lang.String method,
Param[] headers,
Param[] params,
Http.RequestBody requestBody,
Http.ResponseHandler<T> responseHandler)
Make a synchronous HTTP request to an Ably endpoint, using the Ably auth credentials and fallback hosts if necessary
|
<T> T |
del(java.lang.String path,
Param[] headers,
Param[] params,
Http.ResponseHandler<T> responseHandler)
HTTP DEL for Ably host, with fallbacks
|
<T> T |
exec(java.lang.String path,
java.lang.String method,
Param[] headers,
Param[] params,
Http.RequestBody requestBody,
Http.ResponseHandler<T> responseHandler)
HTTP request for Ably host, with fallbacks
|
void |
finalize() |
<T> T |
get(java.lang.String path,
Param[] headers,
Param[] params,
Http.ResponseHandler<T> responseHandler)
HTTP GET for Ably host, with fallbacks
|
java.lang.String |
getHost()
Gets host for this HTTP client
|
<T> T |
getUri(java.lang.String uri,
Param[] headers,
Param[] params,
Http.ResponseHandler<T> responseHandler)
HTTP GET for non-Ably host
|
byte[] |
getUrl(java.lang.String url)
Simple HTTP GET; no auth, headers, returning response body as byte[]
|
java.lang.String |
getUrlString(java.lang.String url)
Simple HTTP GET; no auth, headers, returning response body as string
|
<T> T |
httpExecute(java.net.URL url,
java.net.Proxy proxy,
java.lang.String method,
Param[] headers,
Http.RequestBody requestBody,
boolean withCredentials,
Http.ResponseHandler<T> responseHandler)
Make a synchronous HTTP request specified by URL and proxy
|
<T> T |
httpExecute(java.net.URL url,
java.lang.String method,
Param[] headers,
Http.RequestBody requestBody,
Http.ResponseHandler<T> responseHandler)
Make a synchronous HTTP request to non-Ably endpoint, specified by URL and using the configured proxy, if any
|
<T> T |
httpExecuteWithRetry(java.net.URL url,
java.lang.String method,
Param[] headers,
Http.RequestBody requestBody,
Http.ResponseHandler<T> responseHandler,
boolean allowAblyAuth)
Make a synchronous HTTP request specified by URL and proxy, retrying if necessary on WWW-Authenticate
|
<T> T |
post(java.lang.String path,
Param[] headers,
Param[] params,
Http.RequestBody requestBody,
Http.ResponseHandler<T> responseHandler)
HTTP POST for Ably host, with fallbacks
|
<T> T |
postUri(java.lang.String uri,
Param[] headers,
Param[] params,
Http.ResponseHandler<T> responseHandler)
HTTP POST with data in form encoding for non-Ably host
|
<T> T |
put(java.lang.String path,
Param[] headers,
Param[] params,
Http.RequestBody requestBody,
Http.ResponseHandler<T> responseHandler)
HTTP PUT for Ably host, with fallbacks
|
void |
setHost(java.lang.String host)
Sets host for this HTTP client
|
public static final java.lang.String GET
public static final java.lang.String PUT
public static final java.lang.String POST
public static final java.lang.String DELETE
public Http(ClientOptions options, Auth auth) throws AblyException
AblyExceptionpublic void setHost(java.lang.String host)
host - URL stringpublic java.lang.String getHost()
public java.lang.String getUrlString(java.lang.String url)
throws AblyException
url - AblyExceptionpublic byte[] getUrl(java.lang.String url)
throws AblyException
url - AblyExceptionpublic <T> T getUri(java.lang.String uri,
Param[] headers,
Param[] params,
Http.ResponseHandler<T> responseHandler)
throws AblyException
uri - headers - params - responseHandler - AblyExceptionpublic <T> T get(java.lang.String path,
Param[] headers,
Param[] params,
Http.ResponseHandler<T> responseHandler)
throws AblyException
path - headers - params - responseHandler - AblyExceptionpublic <T> T put(java.lang.String path,
Param[] headers,
Param[] params,
Http.RequestBody requestBody,
Http.ResponseHandler<T> responseHandler)
throws AblyException
path - headers - params - requestBody - responseHandler - AblyExceptionpublic <T> T postUri(java.lang.String uri,
Param[] headers,
Param[] params,
Http.ResponseHandler<T> responseHandler)
throws AblyException
uri - headers - params - responseHandler - AblyExceptionpublic <T> T post(java.lang.String path,
Param[] headers,
Param[] params,
Http.RequestBody requestBody,
Http.ResponseHandler<T> responseHandler)
throws AblyException
path - headers - params - requestBody - responseHandler - AblyExceptionpublic <T> T del(java.lang.String path,
Param[] headers,
Param[] params,
Http.ResponseHandler<T> responseHandler)
throws AblyException
path - headers - params - responseHandler - AblyExceptionpublic <T> T exec(java.lang.String path,
java.lang.String method,
Param[] headers,
Param[] params,
Http.RequestBody requestBody,
Http.ResponseHandler<T> responseHandler)
throws AblyException
path - method - headers - params - requestBody - responseHandler - AblyExceptionpublic void finalize()
finalize in class java.lang.Objectpublic <T> T ablyHttpExecute(java.lang.String path,
java.lang.String method,
Param[] headers,
Param[] params,
Http.RequestBody requestBody,
Http.ResponseHandler<T> responseHandler)
throws AblyException
path - method - headers - params - requestBody - responseHandler - AblyExceptionpublic <T> T httpExecute(java.net.URL url,
java.lang.String method,
Param[] headers,
Http.RequestBody requestBody,
Http.ResponseHandler<T> responseHandler)
throws AblyException
url - method - headers - requestBody - withCredentials - responseHandler - AblyExceptionpublic <T> T httpExecute(java.net.URL url,
java.net.Proxy proxy,
java.lang.String method,
Param[] headers,
Http.RequestBody requestBody,
boolean withCredentials,
Http.ResponseHandler<T> responseHandler)
throws AblyException
url - proxy - method - headers - requestBody - withCredentials - responseHandler - AblyExceptionpublic <T> T httpExecuteWithRetry(java.net.URL url,
java.lang.String method,
Param[] headers,
Http.RequestBody requestBody,
Http.ResponseHandler<T> responseHandler,
boolean allowAblyAuth)
throws AblyException
url - proxy - method - headers - requestBody - responseHandler - AblyException