Top Description Inners Fields Constructors Methods
io.undertow.util

public Class URLUtils

extends Object
Class Inheritance
Imports
java.io.UnsupportedEncodingException, java.util.regex.Pattern, org.xnio.OptionMap, io.undertow.UndertowMessages, .UndertowOptions, io.undertow.server.HttpServerExchange

Utilities for dealing with URLs
Authors
Stuart Douglas, Andre Schaefer

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract static class

Field Summary

Modifier and TypeField and Description
private static final URLUtils.QueryStringParser
private static final char
private static final URLUtils.QueryStringParser
private static final Pattern

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

The decoded URL
decode
(String
The string to decode
s
,
String
The encoding
enc
,
boolean
If slash characters should be decoded
decodeSlash
,
StringBuilder
The string builder to use as a buffer.
buffer
)

Decodes a URL.

public static String

Returns:

The decoded URL
decode
(String
The string to decode
s
,
String
The encoding
enc
,
boolean
If slash characters should be decoded
decodeSlash
,
boolean formEncoding, StringBuilder
The string builder to use as a buffer.
buffer
)

Decodes a URL.

private static byte[]
expandBytes(byte[] bytes)

public static boolean
public static boolean
getSlashDecodingFlag(final boolean allowEncodedSlash, final Boolean decodeSlash)

public static boolean

Returns:

true if location is considered absolute
isAbsoluteUrl
(String
location to check, null = relative, having scheme = absolute
location
)

Test if provided location is an absolute URI or not.

public static String

Returns:

a normalized (with respect to slashes) result
normalizeSlashes
(final String
the path to normalize
path
)

Adds a '/' prefix to the beginning of a path if one isn't present and removes trailing slashes if any are present.

public static int
parsePathParams(final String string, final HttpServerExchange exchange, final String charset, final boolean doDecode, int maxParameters)

public static void
parsePathParms(final String string, final HttpServerExchange exchange, final String charset, final boolean doDecode, int maxParameters)
Deprecated

public static void
parseQueryString(final String string, final HttpServerExchange exchange, final String charset, final boolean doDecode, int maxParameters)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

PATH_PARAM_PARSERback to summary
private static final URLUtils.QueryStringParser PATH_PARAM_PARSER
PATH_SEPARATORback to summary
private static final char PATH_SEPARATOR
QUERY_STRING_PARSERback to summary
private static final URLUtils.QueryStringParser QUERY_STRING_PARSER
SCHEME_PATTERNback to summary
private static final Pattern SCHEME_PATTERN

Constructor Detail

URLUtilsback to summary
private URLUtils()

Method Detail

decodeback to summary
public static String decode(String s, String enc, boolean decodeSlash, StringBuilder buffer)

Decodes a URL. If the decoding fails for any reason then an IllegalArgumentException will be thrown.

Parameters
s:String

The string to decode

enc:String

The encoding

decodeSlash:boolean

If slash characters should be decoded

buffer:StringBuilder

The string builder to use as a buffer.

Returns:String

The decoded URL

decodeback to summary
public static String decode(String s, String enc, boolean decodeSlash, boolean formEncoding, StringBuilder buffer)

Decodes a URL. If the decoding fails for any reason then an IllegalArgumentException will be thrown.

Parameters
s:String

The string to decode

enc:String

The encoding

decodeSlash:boolean

If slash characters should be decoded

buffer:StringBuilder

The string builder to use as a buffer.

Returns:String

The decoded URL

expandBytesback to summary
private static byte[] expandBytes(byte[] bytes)
getSlashDecodingFlagback to summary
public static boolean getSlashDecodingFlag(final OptionMap options)
getSlashDecodingFlagback to summary
public static boolean getSlashDecodingFlag(final boolean allowEncodedSlash, final Boolean decodeSlash)
isAbsoluteUrlback to summary
public static boolean isAbsoluteUrl(String location)

Test if provided location is an absolute URI or not.

Parameters
location:String

location to check, null = relative, having scheme = absolute

Returns:boolean

true if location is considered absolute

normalizeSlashesback to summary
public static String normalizeSlashes(final String path)

Adds a '/' prefix to the beginning of a path if one isn't present and removes trailing slashes if any are present.

Parameters
path:String

the path to normalize

Returns:String

a normalized (with respect to slashes) result

parsePathParamsback to summary
public static int parsePathParams(final String string, final HttpServerExchange exchange, final String charset, final boolean doDecode, int maxParameters) throws ParameterLimitException
parsePathParmsback to summary
public static void parsePathParms(final String string, final HttpServerExchange exchange, final String charset, final boolean doDecode, int maxParameters) throws ParameterLimitException

Deprecated

Annotations
@Deprecated
parseQueryStringback to summary
public static void parseQueryString(final String string, final HttpServerExchange exchange, final String charset, final boolean doDecode, int maxParameters) throws ParameterLimitException
io.undertow.util back to summary

private abstract Class URLUtils.QueryStringParser

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final boolean
private final char

Constructor Summary

AccessConstructor and Description
pack-priv
QueryStringParser(final char separator, final boolean parseUntilSeparator)

Method Summary

Modifier and TypeMethod and Description
private String
decode(String charset, String attrName, final boolean doDecode)

pack-priv abstract void
handle(final HttpServerExchange exchange, final String key, final String value)

pack-priv int
parse(final String string, final HttpServerExchange exchange, final String charset, final boolean doDecode, int max)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

parseUntilSeparatorback to summary
private final boolean parseUntilSeparator
separatorback to summary
private final char separator

Constructor Detail

QueryStringParserback to summary
pack-priv QueryStringParser(final char separator, final boolean parseUntilSeparator)

Method Detail

decodeback to summary
private String decode(String charset, String attrName, final boolean doDecode) throws UnsupportedEncodingException
handleback to summary
pack-priv abstract void handle(final HttpServerExchange exchange, final String key, final String value)
parseback to summary
pack-priv int parse(final String string, final HttpServerExchange exchange, final String charset, final boolean doDecode, int max) throws ParameterLimitException