public class HttpUtils
extends java.lang.Object
Constructor and Description |
---|
HttpUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
appendUri(java.lang.String baseUri,
java.lang.String path)
Append the given path to the given baseUri.
|
static java.lang.String |
appendUri(java.lang.String baseUri,
java.lang.String path,
boolean escapeDoubleSlash)
Append the given path to the given baseUri.
|
static java.lang.String |
appendUriEncoded(java.lang.String baseUri,
java.lang.String paths)
Append the given path to the given baseUri.
|
static java.lang.String |
encodeParameters(Request<?> request)
Creates an encoded query string from all the parameters in the specified
request.
|
static java.io.InputStream |
fetchFile(java.net.URI uri,
ClientConfiguration config)
Fetches a file from the URI given and returns an input stream to it.
|
static boolean |
isUsingNonDefaultPort(java.net.URI uri)
Returns true if the specified URI is using a non-standard port (i.e.
|
static java.lang.String |
urlDecode(java.lang.String value)
Decode a string for use in the path of a URL; uses URLDecoder.decode,
which decodes a string for use in the query portion of a URL.
|
static java.lang.String |
urlEncode(java.lang.String value,
boolean path)
Encode a string for use in the path of a URL; uses URLEncoder.encode,
(which encodes a string for use in the query portion of a URL), then
applies some postfilters to fix things up per the RFC.
|
static boolean |
usePayloadForQueryParameters(Request<?> request) |
public static java.lang.String urlEncode(java.lang.String value, boolean path)
value
- the value to encodepath
- true if the value is intended to represent a pathpublic static java.lang.String urlDecode(java.lang.String value)
value
- The value to decodepublic static boolean isUsingNonDefaultPort(java.net.URI uri)
uri
- the URI.public static boolean usePayloadForQueryParameters(Request<?> request)
request
- the request.public static java.lang.String encodeParameters(Request<?> request)
request
- The request containing the parameters to encode.public static java.lang.String appendUri(java.lang.String baseUri, java.lang.String path)
baseUri
- the base URI.path
- the path.public static java.lang.String appendUri(java.lang.String baseUri, java.lang.String path, boolean escapeDoubleSlash)
This method will encode the given path but not the given baseUri.
baseUri
- The URI to append to (required, may be relative)path
- The path to append (may be null or empty)escapeDoubleSlash
- Whether double-slash in the path should be
escaped to "/%2F"public static java.lang.String appendUriEncoded(java.lang.String baseUri, java.lang.String paths)
This method will encode the given path but not the given baseUri.
baseUri
- The URI to append to (required, may be relative)paths
- The path array to append (may be null or empty)public static java.io.InputStream fetchFile(java.net.URI uri, ClientConfiguration config) throws java.io.IOException
uri
- the uri of the file to fetchconfig
- optional configuration overridesjava.io.IOException
- on error