public final class RequestUtils
extends java.lang.Object
RequestBuilder
.Modifier and Type | Method and Description |
---|---|
static java.lang.String |
encode(java.lang.String content)
Encode a string into a valid URL string.
|
static okhttp3.RequestBody |
fileBody(java.io.File file,
java.lang.String contentType)
Returns a request body that encapsulates the specified file qualified with the specified content type.
|
static java.lang.String |
getUserAgent()
Gets the user agent.
|
static okhttp3.RequestBody |
inputStreamBody(java.io.InputStream stream,
java.lang.String contentType)
Returns a request body the encapsulates the specified input stream qualified with the specified content type.
|
static java.lang.String |
join(java.lang.Iterable<?> iterable,
java.lang.String separator)
Creates a String of all elements of an iterable, separated by a separator.
|
static <T> java.lang.String |
join(T[] array,
java.lang.String separator)
Creates a String of all elements of an array, separated by a separator.
|
static java.util.Map<java.lang.String,java.lang.Object> |
omit(java.util.Map<java.lang.String,java.lang.Object> params,
java.lang.String... toOmit)
Return a copy of a
Map excluding the given key, or array of keys. |
static java.util.Map<java.lang.String,java.lang.Object> |
pick(java.util.Map<java.lang.String,java.lang.Object> params,
java.lang.String... toPick)
Return a copy of a
Map with only the specified given key, or array of keys. |
public static java.lang.String encode(java.lang.String content)
content
- the contentpublic static java.util.Map<java.lang.String,java.lang.Object> omit(java.util.Map<java.lang.String,java.lang.Object> params, java.lang.String... toOmit)
Map
excluding the given key, or array of keys.params
- the parameterstoOmit
- the keys to omitpublic static java.util.Map<java.lang.String,java.lang.Object> pick(java.util.Map<java.lang.String,java.lang.Object> params, java.lang.String... toPick)
Map
with only the specified given key, or array of keys. If toPick
is empty all
keys will remain in the Map.params
- the parameterstoPick
- the keys to pickpublic static <T> java.lang.String join(T[] array, java.lang.String separator)
T
- the generic typearray
- the arrayseparator
- the separatorpublic static java.lang.String join(java.lang.Iterable<?> iterable, java.lang.String separator)
iterable
- the iterableseparator
- the separatorpublic static java.lang.String getUserAgent()
public static okhttp3.RequestBody fileBody(java.io.File file, java.lang.String contentType)
file
- the file content to POST/PUTcontentType
- the HTTP contentType to use.RequestBody
public static okhttp3.RequestBody inputStreamBody(java.io.InputStream stream, java.lang.String contentType)
stream
- the input stream content to POST/PUTcontentType
- the HTTP contentType to use.RequestBody