Package com.linecorp.armeria.common
Interface RequestTarget
An HTTP request target, as defined in
Section 3.2, RFC 9112.
Note: This interface doesn't support the authority form.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the authority of thisRequestTarget
.static @Nullable RequestTarget
Returns aRequestTarget
parsed and normalized from the specified request target string in the context of client-side application.static @Nullable RequestTarget
Returns aRequestTarget
parsed and normalized from the specified request target string in the context of client-side application.form()
Returns the form of thisRequestTarget
.static @Nullable RequestTarget
Returns aRequestTarget
parsed and normalized from the specified request target string in the context of server-side application.fragment()
Returns the fragment of thisRequestTarget
.Returns the path of thisRequestTarget
, which always starts with'/'
.path()
Returns the path of thisRequestTarget
, which always starts with'/'
.default String
query()
Returns the query of thisRequestTarget
.scheme()
Returns the scheme of thisRequestTarget
.toString()
Returns the string representation of thisRequestTarget
.
-
Method Details
-
forServer
Returns aRequestTarget
parsed and normalized from the specified request target string in the context of server-side application. It rejects an absolute or authority form request target. It also normalizes'#'
into'%2A'
instead of parsing a fragment. UseforClient(String)
if you want to parse an absolute form request target or a fragment.- Parameters:
reqTarget
- the request target string- Returns:
- a
RequestTarget
if parsed and normalized successfully, ornull
otherwise.
-
forClient
Returns aRequestTarget
parsed and normalized from the specified request target string in the context of client-side application. It rejects an authority form request target.- Parameters:
reqTarget
- the request target string- Returns:
- a
RequestTarget
if parsed and normalized successfully, ornull
otherwise. - See Also:
-
forClient
@Nullable static @Nullable RequestTarget forClient(String reqTarget, @Nullable @Nullable String prefix) Returns aRequestTarget
parsed and normalized from the specified request target string in the context of client-side application. It rejects an authority form request target.- Parameters:
reqTarget
- the request target stringprefix
- the prefix to add toreqTarget
. No prefix is added ifnull
or empty.- Returns:
- a
RequestTarget
if parsed and normalized successfully, ornull
otherwise. - See Also:
-
form
RequestTargetForm form()Returns the form of thisRequestTarget
. -
scheme
Returns the scheme of thisRequestTarget
.- Returns:
- a non-empty string if
form()
isRequestTargetForm.ABSOLUTE
.null
otherwise.
-
authority
Returns the authority of thisRequestTarget
.- Returns:
- a non-empty string if
form()
isRequestTargetForm.ABSOLUTE
.null
otherwise.
-
path
String path()Returns the path of thisRequestTarget
, which always starts with'/'
. -
maybePathWithMatrixVariables
String maybePathWithMatrixVariables()Returns the path of thisRequestTarget
, which always starts with'/'
. Unlikepath()
, the returned string contains matrix variables it the original request path contains them.- See Also:
-
query
Returns the query of thisRequestTarget
. -
pathAndQuery
-
fragment
Returns the fragment of thisRequestTarget
. -
toString
String toString()Returns the string representation of thisRequestTarget
.- Overrides:
toString
in classObject
- Returns:
- One of the following:
- An absolute URI if
form()
isRequestTargetForm.ABSOLUTE
, e.g."https://example.com/foo?bar#baz
- Path with query and fragment if
form()
isRequestTargetForm.ORIGIN
, e.g."/foo?bar#baz"
"*"
ifform()
isRequestTargetForm.ASTERISK
- An absolute URI if
-