Class QueryStringDecoder
This decoder can also decode the content of an HTTP POST request whose content type isQueryStringDecoder
decoder = newQueryStringDecoder
("/hello?recipient=world&x=1;y=2"); assert decoder.path().equals("/hello"); assert decoder.parameters().get("recipient").get(0).equals("world"); assert decoder.parameters().get("x").get(0).equals("1"); assert decoder.parameters().get("y").get(0).equals("2");
application/x-www-form-urlencoded
:
HashDOS vulnerability fix As a workaround to the HashDOS vulnerability, the decoder limits the maximum number of decoded key-value parameter pairs, up to 1024 by default, and you can configure it when you construct the decoder by passing an additional integer parameter.QueryStringDecoder
decoder = newQueryStringDecoder
("recipient=world&x=1;y=2", false); ...
This is forked from Netty. See QueryStringDecoder.java .
-
Constructor Summary
ConstructorsConstructorDescriptionQueryStringDecoder
(String uri) Deprecated, for removal: This API element is subject to removal in a future version.Creates a new decoder that decodes the specified URI.QueryStringDecoder
(String uri, boolean hasPath) Deprecated, for removal: This API element is subject to removal in a future version.Creates a new decoder that decodes the specified URI encoded in the specified charset.QueryStringDecoder
(String uri, Charset charset) Deprecated, for removal: This API element is subject to removal in a future version.Creates a new decoder that decodes the specified URI encoded in the specified charset.QueryStringDecoder
(String uri, Charset charset, boolean hasPath) Deprecated, for removal: This API element is subject to removal in a future version.Creates a new decoder that decodes the specified URI encoded in the specified charset.QueryStringDecoder
(String uri, Charset charset, boolean hasPath, int maxParams) Deprecated, for removal: This API element is subject to removal in a future version.Creates a new decoder that decodes the specified URI encoded in the specified charset.QueryStringDecoder
(String uri, Charset charset, boolean hasPath, int maxParams, boolean semicolonIsNormalChar) Deprecated, for removal: This API element is subject to removal in a future version.Creates a new decoder that decodes the specified URI encoded in the specified charset.QueryStringDecoder
(URI uri) Deprecated, for removal: This API element is subject to removal in a future version.Creates a new decoder that decodes the specified URI.QueryStringDecoder
(URI uri, Charset charset) Deprecated, for removal: This API element is subject to removal in a future version.Creates a new decoder that decodes the specified URI encoded in the specified charset.QueryStringDecoder
(URI uri, Charset charset, int maxParams) Deprecated, for removal: This API element is subject to removal in a future version.Creates a new decoder that decodes the specified URI encoded in the specified charset.QueryStringDecoder
(URI uri, Charset charset, int maxParams, boolean semicolonIsNormalChar) Deprecated, for removal: This API element is subject to removal in a future version.Creates a new decoder that decodes the specified URI encoded in the specified charset. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Deprecated, for removal: This API element is subject to removal in a future version.Decodes a bit of a URL encoded by a browser.static String
decodeComponent
(String s, Charset charset) Deprecated, for removal: This API element is subject to removal in a future version.Decodes a bit of a URL encoded by a browser.Deprecated, for removal: This API element is subject to removal in a future version.Returns the decoded key-value parameter pairs of the URI.path()
Deprecated, for removal: This API element is subject to removal in a future version.Returns the decoded path string of the URI.rawPath()
Deprecated, for removal: This API element is subject to removal in a future version.Returns the raw path string of the URI.rawQuery()
Deprecated, for removal: This API element is subject to removal in a future version.Returns raw query string of the URI.toString()
Deprecated, for removal: This API element is subject to removal in a future version.uri()
Deprecated, for removal: This API element is subject to removal in a future version.Returns the uri used to initialize thisQueryStringDecoder
.
-
Constructor Details
-
QueryStringDecoder
Deprecated, for removal: This API element is subject to removal in a future version.Creates a new decoder that decodes the specified URI. The decoder will assume that the query string is encoded in UTF-8. -
QueryStringDecoder
Deprecated, for removal: This API element is subject to removal in a future version.Creates a new decoder that decodes the specified URI encoded in the specified charset. -
QueryStringDecoder
Deprecated, for removal: This API element is subject to removal in a future version.Creates a new decoder that decodes the specified URI encoded in the specified charset. -
QueryStringDecoder
Deprecated, for removal: This API element is subject to removal in a future version.Creates a new decoder that decodes the specified URI encoded in the specified charset. -
QueryStringDecoder
Deprecated, for removal: This API element is subject to removal in a future version.Creates a new decoder that decodes the specified URI encoded in the specified charset. -
QueryStringDecoder
public QueryStringDecoder(String uri, Charset charset, boolean hasPath, int maxParams, boolean semicolonIsNormalChar) Deprecated, for removal: This API element is subject to removal in a future version.Creates a new decoder that decodes the specified URI encoded in the specified charset. -
QueryStringDecoder
Deprecated, for removal: This API element is subject to removal in a future version.Creates a new decoder that decodes the specified URI. The decoder will assume that the query string is encoded in UTF-8. -
QueryStringDecoder
Deprecated, for removal: This API element is subject to removal in a future version.Creates a new decoder that decodes the specified URI encoded in the specified charset. -
QueryStringDecoder
Deprecated, for removal: This API element is subject to removal in a future version.Creates a new decoder that decodes the specified URI encoded in the specified charset. -
QueryStringDecoder
Deprecated, for removal: This API element is subject to removal in a future version.Creates a new decoder that decodes the specified URI encoded in the specified charset.
-
-
Method Details
-
toString
Deprecated, for removal: This API element is subject to removal in a future version. -
uri
Deprecated, for removal: This API element is subject to removal in a future version.Returns the uri used to initialize thisQueryStringDecoder
. -
path
Deprecated, for removal: This API element is subject to removal in a future version.Returns the decoded path string of the URI. -
parameters
Deprecated, for removal: This API element is subject to removal in a future version.Returns the decoded key-value parameter pairs of the URI. -
rawPath
Deprecated, for removal: This API element is subject to removal in a future version.Returns the raw path string of the URI. -
rawQuery
Deprecated, for removal: This API element is subject to removal in a future version.Returns raw query string of the URI. -
decodeComponent
Deprecated, for removal: This API element is subject to removal in a future version.Decodes a bit of a URL encoded by a browser.This is equivalent to calling
decodeComponent(String, Charset)
with the UTF-8 charset (recommended to comply with RFC 3986, Section 2).- Parameters:
s
- The string to decode (can be empty).- Returns:
- The decoded string, or
s
if there's nothing to decode. If the string to decode isnull
, returns an empty string. - Throws:
IllegalArgumentException
- if the string contains a malformed escape sequence.
-
decodeComponent
Deprecated, for removal: This API element is subject to removal in a future version.Decodes a bit of a URL encoded by a browser.The string is expected to be encoded as per RFC 3986, Section 2. This is the encoding used by JavaScript functions
encodeURI
andencodeURIComponent
, but notescape
. For example in this encoding, é (in UnicodeU+00E9
or in UTF-80xC3 0xA9
) is encoded as%C3%A9
or%c3%a9
.This is essentially equivalent to calling
URLDecoder.decode(String, String)
except that it's over 2x faster and generates less garbage for the GC. Actually this function doesn't allocate any memory if there's nothing to decode, the argument itself is returned.- Parameters:
s
- The string to decode (can be empty).charset
- The charset to use to decode the string (should really beStandardCharsets.UTF_8
.- Returns:
- The decoded string, or
s
if there's nothing to decode. If the string to decode isnull
, returns an empty string. - Throws:
IllegalArgumentException
- if the string contains a malformed escape sequence.
-
QueryStringDecoder
instead.