public final class SdkHttpUtils extends Object
Modifier and Type | Method and Description |
---|---|
static Stream<String> |
allMatchingHeaders(Map<String,List<String>> headers,
String header)
Perform a case-insensitive search for a particular header in the provided map of headers.
|
static Stream<String> |
allMatchingHeadersFromCollection(Map<String,List<String>> headersToSearch,
Collection<String> headersToFind)
Perform a case-insensitive search for a particular header in the provided map of headers.
|
static String |
appendUri(String baseUri,
String path)
Append the given path to the given baseUri, separating them with a slash, if required.
|
static Optional<String> |
encodeAndFlattenFormData(Map<String,List<String>> rawFormData)
Encode the provided form data using
encodeFormData(Map) and then flatten them into a string that
can be used as the body of a form data request. |
static Optional<String> |
encodeAndFlattenQueryParameters(Map<String,List<String>> rawQueryParameters)
Encode the provided query parameters using
encodeQueryParameters(Map) and then flatten them into a string that
can be used as the query string in a URL. |
static Map<String,List<String>> |
encodeFormData(Map<String,List<String>> rawFormData)
Encode each of the keys and values in the provided form data using
formDataEncode(String) . |
static Map<String,List<String>> |
encodeQueryParameters(Map<String,List<String>> rawQueryParameters)
Encode each of the keys and values in the provided query parameters using
urlEncode(String) . |
static Optional<String> |
firstMatchingHeader(Map<String,List<String>> headers,
String header)
Perform a case-insensitive search for a particular header in the provided map of headers, returning the first matching
header, if one is found.
|
static Optional<String> |
firstMatchingHeaderFromCollection(Map<String,List<String>> headersToSearch,
Collection<String> headersToFind)
Perform a case-insensitive search for a set of headers in the provided map of headers, returning the first matching
header, if one is found.
|
static Optional<String> |
flattenQueryParameters(Map<String,List<String>> toFlatten)
Flatten the provided query parameters into a string that can be used as the query string in a URL.
|
static String |
formDataEncode(String value)
Encode a string according to RFC 1630: encoding for form data.
|
static boolean |
isSingleHeader(String h) |
static boolean |
isUsingStandardPort(String protocol,
Integer port)
Returns true if the specified port is the standard port for the given protocol.
|
static int |
standardPort(String protocol)
Retrieve the standard port for the provided protocol.
|
static Map<String,List<String>> |
uriParams(URI uri)
Extracts query parameters from the given URI
|
static String |
urlDecode(String value)
Decode the string according to RFC 3986: encoding for URI paths, query strings, etc.
|
static String |
urlEncode(String value)
Encode a string according to RFC 3986: encoding for URI paths, query strings, etc.
|
static String |
urlEncodeIgnoreSlashes(String value)
Encode a string according to RFC 3986, but ignore "/" characters.
|
public static String urlEncode(String value)
public static String urlEncodeIgnoreSlashes(String value)
public static String formDataEncode(String value)
public static String urlDecode(String value)
Assumes the decoded string is UTF-8 encoded.
value
- The string to decode.public static Map<String,List<String>> encodeQueryParameters(Map<String,List<String>> rawQueryParameters)
urlEncode(String)
.public static Map<String,List<String>> encodeFormData(Map<String,List<String>> rawFormData)
formDataEncode(String)
.public static Optional<String> encodeAndFlattenQueryParameters(Map<String,List<String>> rawQueryParameters)
encodeQueryParameters(Map)
and then flatten them into a string that
can be used as the query string in a URL. The result is not prepended with "?".public static Optional<String> encodeAndFlattenFormData(Map<String,List<String>> rawFormData)
encodeFormData(Map)
and then flatten them into a string that
can be used as the body of a form data request.public static Optional<String> flattenQueryParameters(Map<String,List<String>> toFlatten)
public static boolean isUsingStandardPort(String protocol, Integer port)
URI
's default value) are treated as standard ports.public static int standardPort(String protocol)
public static String appendUri(String baseUri, String path)
public static Stream<String> allMatchingHeaders(Map<String,List<String>> headers, String header)
headers
- The headers to search.header
- The header to search for (case insensitively).public static Stream<String> allMatchingHeadersFromCollection(Map<String,List<String>> headersToSearch, Collection<String> headersToFind)
headersToSearch
- The headers to search.headersToFind
- The headers to search for (case insensitively).public static Optional<String> firstMatchingHeader(Map<String,List<String>> headers, String header)
headers
- The headers to search.header
- The header to search for (case insensitively).public static Optional<String> firstMatchingHeaderFromCollection(Map<String,List<String>> headersToSearch, Collection<String> headersToFind)
headersToSearch
- The headers to search.headersToFind
- The header to search for (case insensitively).public static boolean isSingleHeader(String h)
Copyright © 2020. All rights reserved.