public final class DbxRequestUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
DbxRequestUtil.RequestMaker<T,E extends java.lang.Throwable> |
static class |
DbxRequestUtil.ResponseHandler<T> |
Modifier and Type | Field and Description |
---|---|
static DbxGlobalCallbackFactory |
sharedCallbackFactory |
Constructor and Description |
---|
DbxRequestUtil() |
Modifier and Type | Method and Description |
---|---|
static java.util.List<HttpRequestor.Header> |
addAuthHeader(java.util.List<HttpRequestor.Header> headers,
java.lang.String accessToken) |
static java.util.List<HttpRequestor.Header> |
addBasicAuthHeader(java.util.List<HttpRequestor.Header> headers,
java.lang.String username,
java.lang.String password) |
static java.util.List<HttpRequestor.Header> |
addPathRootHeader(java.util.List<HttpRequestor.Header> headers,
PathRoot pathRoot) |
static java.util.List<HttpRequestor.Header> |
addSelectAdminHeader(java.util.List<HttpRequestor.Header> headers,
java.lang.String adminId) |
static java.util.List<HttpRequestor.Header> |
addSelectUserHeader(java.util.List<HttpRequestor.Header> headers,
java.lang.String memberId) |
static java.util.List<HttpRequestor.Header> |
addUserAgentHeader(java.util.List<HttpRequestor.Header> headers,
DbxRequestConfig requestConfig,
java.lang.String sdkUserAgentIdentifier) |
static java.util.List<HttpRequestor.Header> |
addUserLocaleHeader(java.util.List<HttpRequestor.Header> headers,
DbxRequestConfig requestConfig) |
static java.lang.String |
buildUri(java.lang.String host,
java.lang.String path) |
static java.lang.String |
buildUrlWithParams(java.lang.String userLocale,
java.lang.String host,
java.lang.String path,
java.lang.String[] params) |
static HttpRequestor.Header |
buildUserAgentHeader(DbxRequestConfig requestConfig,
java.lang.String sdkUserAgentIdentifier) |
static <T> T |
doGet(DbxRequestConfig requestConfig,
java.lang.String accessToken,
java.lang.String sdkUserAgentIdentifier,
java.lang.String host,
java.lang.String path,
java.lang.String[] params,
java.util.List<HttpRequestor.Header> headers,
DbxRequestUtil.ResponseHandler<T> handler) |
static <T> T |
doPost(DbxRequestConfig requestConfig,
java.lang.String accessToken,
java.lang.String sdkUserAgentIdentifier,
java.lang.String host,
java.lang.String path,
java.lang.String[] params,
java.util.List<HttpRequestor.Header> headers,
DbxRequestUtil.ResponseHandler<T> handler) |
static <T> T |
doPostNoAuth(DbxRequestConfig requestConfig,
java.lang.String sdkUserAgentIdentifier,
java.lang.String host,
java.lang.String path,
java.lang.String[] params,
java.util.List<HttpRequestor.Header> headers,
DbxRequestUtil.ResponseHandler<T> handler) |
static java.lang.String |
encodeUrlParam(java.lang.String s) |
static <T> T |
finishResponse(HttpRequestor.Response response,
DbxRequestUtil.ResponseHandler<T> handler) |
static java.lang.String |
getContentType(HttpRequestor.Response response) |
static java.lang.String |
getFirstHeader(HttpRequestor.Response response,
java.lang.String name) |
static java.lang.String |
getFirstHeaderMaybe(HttpRequestor.Response response,
java.lang.String name) |
static java.lang.String |
getRequestId(HttpRequestor.Response response) |
static byte[] |
loadErrorBody(HttpRequestor.Response response) |
static java.lang.String |
parseErrorBody(java.lang.String requestId,
int statusCode,
byte[] body) |
static <T> T |
readJsonFromErrorMessage(StoneSerializer<T> serializer,
java.lang.String message,
java.lang.String requestId) |
static <T> T |
readJsonFromResponse(JsonReader<T> reader,
HttpRequestor.Response response) |
static java.util.List<HttpRequestor.Header> |
removeAuthHeader(java.util.List<HttpRequestor.Header> headers) |
static <T,E extends java.lang.Throwable> |
runAndRetry(int maxRetries,
DbxRequestUtil.RequestMaker<T,E> requestMaker) |
static HttpRequestor.Response |
startGet(DbxRequestConfig requestConfig,
java.lang.String accessToken,
java.lang.String sdkUserAgentIdentifier,
java.lang.String host,
java.lang.String path,
java.lang.String[] params,
java.util.List<HttpRequestor.Header> headers)
Convenience function for making HTTP GET requests.
|
static HttpRequestor.Response |
startPostNoAuth(DbxRequestConfig requestConfig,
java.lang.String sdkUserAgentIdentifier,
java.lang.String host,
java.lang.String path,
java.lang.String[] params,
java.util.List<HttpRequestor.Header> headers)
Convenience function for making HTTP POST requests.
|
static HttpRequestor.Response |
startPostRaw(DbxRequestConfig requestConfig,
java.lang.String sdkUserAgentIdentifier,
java.lang.String host,
java.lang.String path,
byte[] body,
java.util.List<HttpRequestor.Header> headers)
Convenience function for making HTTP POST requests.
|
static HttpRequestor.Uploader |
startPut(DbxRequestConfig requestConfig,
java.lang.String accessToken,
java.lang.String sdkUserAgentIdentifier,
java.lang.String host,
java.lang.String path,
java.lang.String[] params,
java.util.List<HttpRequestor.Header> headers)
Convenience function for making HTTP PUT requests.
|
static java.lang.String[] |
toParamsArray(java.util.Map<java.lang.String,java.lang.String> params) |
static DbxException |
unexpectedStatus(HttpRequestor.Response response) |
static DbxException |
unexpectedStatus(HttpRequestor.Response response,
java.lang.String userId) |
public static DbxGlobalCallbackFactory sharedCallbackFactory
public static java.lang.String encodeUrlParam(java.lang.String s)
public static java.lang.String buildUrlWithParams(java.lang.String userLocale, java.lang.String host, java.lang.String path, java.lang.String[] params)
public static java.lang.String[] toParamsArray(java.util.Map<java.lang.String,java.lang.String> params)
public static java.lang.String buildUri(java.lang.String host, java.lang.String path)
public static java.util.List<HttpRequestor.Header> addAuthHeader(java.util.List<HttpRequestor.Header> headers, java.lang.String accessToken)
public static java.util.List<HttpRequestor.Header> addSelectUserHeader(java.util.List<HttpRequestor.Header> headers, java.lang.String memberId)
public static java.util.List<HttpRequestor.Header> addSelectAdminHeader(java.util.List<HttpRequestor.Header> headers, java.lang.String adminId)
public static java.util.List<HttpRequestor.Header> addBasicAuthHeader(java.util.List<HttpRequestor.Header> headers, java.lang.String username, java.lang.String password)
public static java.util.List<HttpRequestor.Header> addUserAgentHeader(java.util.List<HttpRequestor.Header> headers, DbxRequestConfig requestConfig, java.lang.String sdkUserAgentIdentifier)
public static java.util.List<HttpRequestor.Header> addUserLocaleHeader(java.util.List<HttpRequestor.Header> headers, DbxRequestConfig requestConfig)
public static HttpRequestor.Header buildUserAgentHeader(DbxRequestConfig requestConfig, java.lang.String sdkUserAgentIdentifier)
public static java.util.List<HttpRequestor.Header> addPathRootHeader(java.util.List<HttpRequestor.Header> headers, PathRoot pathRoot)
public static java.util.List<HttpRequestor.Header> removeAuthHeader(java.util.List<HttpRequestor.Header> headers)
public static HttpRequestor.Response startGet(DbxRequestConfig requestConfig, java.lang.String accessToken, java.lang.String sdkUserAgentIdentifier, java.lang.String host, java.lang.String path, java.lang.String[] params, java.util.List<HttpRequestor.Header> headers) throws NetworkIOException
NetworkIOException
public static HttpRequestor.Uploader startPut(DbxRequestConfig requestConfig, java.lang.String accessToken, java.lang.String sdkUserAgentIdentifier, java.lang.String host, java.lang.String path, java.lang.String[] params, java.util.List<HttpRequestor.Header> headers) throws NetworkIOException
NetworkIOException
public static HttpRequestor.Response startPostNoAuth(DbxRequestConfig requestConfig, java.lang.String sdkUserAgentIdentifier, java.lang.String host, java.lang.String path, java.lang.String[] params, java.util.List<HttpRequestor.Header> headers) throws NetworkIOException
NetworkIOException
public static HttpRequestor.Response startPostRaw(DbxRequestConfig requestConfig, java.lang.String sdkUserAgentIdentifier, java.lang.String host, java.lang.String path, byte[] body, java.util.List<HttpRequestor.Header> headers) throws NetworkIOException
NetworkIOException
public static byte[] loadErrorBody(HttpRequestor.Response response) throws NetworkIOException
NetworkIOException
public static java.lang.String parseErrorBody(java.lang.String requestId, int statusCode, byte[] body) throws BadResponseException
BadResponseException
public static DbxException unexpectedStatus(HttpRequestor.Response response) throws NetworkIOException, BadResponseException
public static DbxException unexpectedStatus(HttpRequestor.Response response, java.lang.String userId) throws NetworkIOException, BadResponseException
public static <T> T readJsonFromResponse(JsonReader<T> reader, HttpRequestor.Response response) throws BadResponseException, NetworkIOException
public static <T> T readJsonFromErrorMessage(StoneSerializer<T> serializer, java.lang.String message, java.lang.String requestId) throws com.fasterxml.jackson.core.JsonParseException
com.fasterxml.jackson.core.JsonParseException
public static <T> T doGet(DbxRequestConfig requestConfig, java.lang.String accessToken, java.lang.String sdkUserAgentIdentifier, java.lang.String host, java.lang.String path, java.lang.String[] params, java.util.List<HttpRequestor.Header> headers, DbxRequestUtil.ResponseHandler<T> handler) throws DbxException
DbxException
public static <T> T doPost(DbxRequestConfig requestConfig, java.lang.String accessToken, java.lang.String sdkUserAgentIdentifier, java.lang.String host, java.lang.String path, java.lang.String[] params, java.util.List<HttpRequestor.Header> headers, DbxRequestUtil.ResponseHandler<T> handler) throws DbxException
DbxException
public static <T> T doPostNoAuth(DbxRequestConfig requestConfig, java.lang.String sdkUserAgentIdentifier, java.lang.String host, java.lang.String path, java.lang.String[] params, java.util.List<HttpRequestor.Header> headers, DbxRequestUtil.ResponseHandler<T> handler) throws DbxException
DbxException
public static <T> T finishResponse(HttpRequestor.Response response, DbxRequestUtil.ResponseHandler<T> handler) throws DbxException
DbxException
public static java.lang.String getFirstHeader(HttpRequestor.Response response, java.lang.String name) throws BadResponseException
BadResponseException
public static java.lang.String getFirstHeaderMaybe(HttpRequestor.Response response, java.lang.String name)
public static java.lang.String getRequestId(HttpRequestor.Response response)
public static java.lang.String getContentType(HttpRequestor.Response response)
public static <T,E extends java.lang.Throwable> T runAndRetry(int maxRetries, DbxRequestUtil.RequestMaker<T,E> requestMaker) throws DbxException, E extends java.lang.Throwable
DbxException
E extends java.lang.Throwable