public final class HttpEncoderDecoderUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
appendQueryParam(String url,
String queryParamName,
String queryParamValue)
Appends a query parameter to an URL that may or may not contain query parameters already.
|
static MultiMap<String,String> |
decodeQueryString(String queryString)
Converts a query-string from a request url into a
MultiMap . |
static Map<String,String> |
decodeUriParams(String pathWithUriParams,
String requestPath)
Decodes uri params from a request path
|
static MultiMap<String,String> |
decodeUrlEncodedBody(String queryString,
Charset encoding)
Converts an url-encoded body into a
MultiMap with a given encoding. |
static String |
encodeQueryString(Map<String,String> parameters)
Converts a map to a request url query-string form.
|
static String |
encodeSpaces(String path)
Encodes spaces in a path, replacing them by %20.
|
static String |
encodeString(Map parameters,
Charset encoding)
Converts a map to a request url query-string form.
|
static String |
extractPath(String uri)
Extracts the path (what's left of the
? character) from the passed uri. |
static String |
extractQueryParams(String uri)
Extracts the query parameters (what's right of the
? character) from the passed uri. |
public static String extractPath(String uri)
?
character) from the passed uri.uri
- the uri to extract the path frompublic static String extractQueryParams(String uri)
?
character) from the passed uri.uri
- the uri to extract the parameters frompublic static MultiMap<String,String> decodeQueryString(String queryString)
MultiMap
.
This is the inverse of encodeQueryString(Map)
.
queryString
- the query string to parsequeryString
public static String encodeQueryString(Map<String,String> parameters)
This is the inverse of decodeQueryString(String)
.
parameters
- a map representation of the queryString
public static MultiMap<String,String> decodeUrlEncodedBody(String queryString, Charset encoding)
MultiMap
with a given encoding.
This is the inverse of #encodeString(String, Charset)
.
queryString
- the string to parseencoding
- URLDecoder.decode(String, String)
.queryString
public static Map<String,String> decodeUriParams(String pathWithUriParams, String requestPath)
pathWithUriParams
- path with uri param place holdersrequestPath
- request pathpublic static String encodeString(Map parameters, Charset encoding)
This is the inverse of decodeUrlEncodedBody(String, Charset)
.
parameters
- a map representation of the queryString
encoding
- URLDecoder.decode(String, String)
.public static String encodeSpaces(String path)
path
- Path that may contain spacespublic static String appendQueryParam(String url, String queryParamName, String queryParamValue)
url
- base URL to apply the new query parameterqueryParamName
- query parameter namequeryParamValue
- query parameter valueCopyright © 2018. All rights reserved.