Package io.servicetalk.http.utils
Class HttpRequestUriUtils
- java.lang.Object
-
- io.servicetalk.http.utils.HttpRequestUriUtils
-
public final class HttpRequestUriUtils extends java.lang.Object
Helper methods for computing effective request URIs according to RFC 7230, section 5.5 and base URIs (which are effective request URIs with/
as path, and no query nor fragment.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
getBaseRequestUri(ConnectionContext ctx, HttpRequestMetaData metaData, boolean includeUserInfo)
Get the base URI for the providedConnectionContext
andHttpRequestMetaData
.static java.lang.String
getBaseRequestUri(ConnectionContext ctx, HttpRequestMetaData metaData, java.lang.String fixedScheme, java.lang.String fixedAuthority, boolean includeUserInfo)
Get the base URI for the providedConnectionContext
andHttpRequestMetaData
.static java.lang.String
getEffectiveRequestUri(HttpRequestMetaData metaData, java.lang.String fixedScheme, java.lang.String fixedAuthority, boolean includeUserInfo)
Get the effective request URI for the providedHttpRequestMetaData
.static java.lang.String
getEffectiveRequestUri(ConnectionContext ctx, HttpRequestMetaData metaData, boolean includeUserInfo)
Get the effective request URI for the providedConnectionContext
andHttpRequestMetaData
.static java.lang.String
getEffectiveRequestUri(ConnectionContext ctx, HttpRequestMetaData metaData, java.lang.String fixedScheme, java.lang.String fixedAuthority, boolean includeUserInfo)
Get the effective request URI for the providedConnectionContext
andHttpRequestMetaData
.
-
-
-
Method Detail
-
getEffectiveRequestUri
public static java.lang.String getEffectiveRequestUri(ConnectionContext ctx, HttpRequestMetaData metaData, boolean includeUserInfo)
Get the effective request URI for the providedConnectionContext
andHttpRequestMetaData
.For example, for this origin-form request:
GET /pub/WWW/TheProject.html HTTP/1.1 Host: www.example.org:8080
the effective request URI will be:http://www.example.org:8080/pub/WWW/TheProject.html
- Parameters:
ctx
- theConnectionContext
to use.metaData
- theHttpRequestMetaData
to use.includeUserInfo
-true
if the deprecated user info sub-component must be included (see RFC 7230, section 2.7.1).- Returns:
- an effective request URI as
String
.
-
getEffectiveRequestUri
public static java.lang.String getEffectiveRequestUri(ConnectionContext ctx, HttpRequestMetaData metaData, @Nullable java.lang.String fixedScheme, @Nullable java.lang.String fixedAuthority, boolean includeUserInfo)
Get the effective request URI for the providedConnectionContext
andHttpRequestMetaData
.For example, for this origin-form request:
GET /pub/WWW/TheProject.html HTTP/1.1 Host: www.example.org:8080
and afixedAuthority
of"example.com"
the effective request URI will be:http://example.com/pub/WWW/TheProject.html
- Parameters:
ctx
- theConnectionContext
to use.metaData
- theHttpRequestMetaData
to use.fixedScheme
- the configured fixed scheme asString
, ornull
if none is set.fixedAuthority
- the configured fixed authority asString
, ornull
if none is set.includeUserInfo
-true
if the deprecated user info sub-component must be included (see RFC 7230, section 2.7.1). Note that this flag has no effect on any user info that could be provided infixedAuthority
.- Returns:
- an effective request URI as
String
. - Throws:
java.lang.IllegalArgumentException
- iffixedScheme
is notnull
and is nothttp
norhttps
.
-
getEffectiveRequestUri
public static java.lang.String getEffectiveRequestUri(HttpRequestMetaData metaData, java.lang.String fixedScheme, java.lang.String fixedAuthority, boolean includeUserInfo)
Get the effective request URI for the providedHttpRequestMetaData
.For example, for this origin-form request:
GET /pub/WWW/TheProject.html HTTP/1.1 Host: www.example.org:8080
and afixedAuthority
of"example.com"
the effective request URI will be:http://example.com/pub/WWW/TheProject.html
- Parameters:
metaData
- theHttpRequestMetaData
to use.fixedScheme
- the configured fixed scheme asString
, ornull
if none is set.fixedAuthority
- the configured fixed authority asString
, ornull
if none is set.includeUserInfo
-true
if the deprecated user info sub-component must be included (see RFC 7230, section 2.7.1). Note that this flag has no effect on any user info that could be provided infixedAuthority
.- Returns:
- an effective request URI as
String
. - Throws:
java.lang.IllegalArgumentException
- iffixedScheme
is notnull
and is nothttp
norhttps
.
-
getBaseRequestUri
public static java.lang.String getBaseRequestUri(ConnectionContext ctx, HttpRequestMetaData metaData, boolean includeUserInfo)
Get the base URI for the providedConnectionContext
andHttpRequestMetaData
.For example, for this origin-form request:
GET /pub/WWW/TheProject.html HTTP/1.1 Host: www.example.org:8080
the base request URI will be:http://www.example.org:8080/
- Parameters:
ctx
- theConnectionContext
to use.metaData
- theHttpRequestMetaData
to use.includeUserInfo
-true
if the deprecated user info sub-component must be included (see RFC 7230, section 2.7.1).- Returns:
- a base request URI as
String
.
-
getBaseRequestUri
public static java.lang.String getBaseRequestUri(ConnectionContext ctx, HttpRequestMetaData metaData, @Nullable java.lang.String fixedScheme, @Nullable java.lang.String fixedAuthority, boolean includeUserInfo)
Get the base URI for the providedConnectionContext
andHttpRequestMetaData
.For example, for this origin-form request:
GET /pub/WWW/TheProject.html HTTP/1.1 Host: www.example.org:8080
and afixedAuthority
of"example.com"
the base request URI will be:http://example.com/
- Parameters:
ctx
- theConnectionContext
to use.metaData
- theHttpRequestMetaData
to use.fixedScheme
- the configured fixed scheme asString
, ornull
if none is set.fixedAuthority
- the configured fixed authority asString
, ornull
if none is set.includeUserInfo
-true
if the deprecated user info sub-component must be included (see RFC 7230, section 2.7.1). Note that this flag has no effect on any user info that could be provided infixedAuthority
.- Returns:
- a base request URI as
String
. - Throws:
java.lang.IllegalArgumentException
- iffixedScheme
is notnull
and is nothttp
norhttps
.
-
-