Package io.servicetalk.http.utils
Class HttpRequestUriUtils
java.lang.Object
io.servicetalk.http.utils.HttpRequestUriUtils
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
Modifier and TypeMethodDescriptionstatic StringgetBaseRequestUri(ConnectionContext ctx, HttpRequestMetaData metaData, boolean includeUserInfo) Get the base URI for the providedConnectionContextandHttpRequestMetaData.static StringgetBaseRequestUri(ConnectionContext ctx, HttpRequestMetaData metaData, String fixedScheme, String fixedAuthority, boolean includeUserInfo) Get the base URI for the providedConnectionContextandHttpRequestMetaData.static StringgetEffectiveRequestUri(HttpRequestMetaData metaData, String fixedScheme, String fixedAuthority, boolean includeUserInfo) Get the effective request URI for the providedHttpRequestMetaData.static StringgetEffectiveRequestUri(ConnectionContext ctx, HttpRequestMetaData metaData, boolean includeUserInfo) Get the effective request URI for the providedConnectionContextandHttpRequestMetaData.static StringgetEffectiveRequestUri(ConnectionContext ctx, HttpRequestMetaData metaData, String fixedScheme, String fixedAuthority, boolean includeUserInfo) Get the effective request URI for the providedConnectionContextandHttpRequestMetaData.
-
Method Details
-
getEffectiveRequestUri
public static String getEffectiveRequestUri(ConnectionContext ctx, HttpRequestMetaData metaData, boolean includeUserInfo) Get the effective request URI for the providedConnectionContextandHttpRequestMetaData.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- theConnectionContextto use.metaData- theHttpRequestMetaDatato use.includeUserInfo-trueif 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 String getEffectiveRequestUri(ConnectionContext ctx, HttpRequestMetaData metaData, @Nullable String fixedScheme, @Nullable String fixedAuthority, boolean includeUserInfo) Get the effective request URI for the providedConnectionContextandHttpRequestMetaData.For example, for this origin-form request:
GET /pub/WWW/TheProject.html HTTP/1.1 Host: www.example.org:8080
and afixedAuthorityof"example.com"the effective request URI will be:http://example.com/pub/WWW/TheProject.html
- Parameters:
ctx- theConnectionContextto use.metaData- theHttpRequestMetaDatato use.fixedScheme- the configured fixed scheme asString, ornullif none is set.fixedAuthority- the configured fixed authority asString, ornullif none is set.includeUserInfo-trueif 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:
IllegalArgumentException- iffixedSchemeis notnulland is nothttpnorhttps.
-
getEffectiveRequestUri
public static String getEffectiveRequestUri(HttpRequestMetaData metaData, String fixedScheme, 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 afixedAuthorityof"example.com"the effective request URI will be:http://example.com/pub/WWW/TheProject.html
- Parameters:
metaData- theHttpRequestMetaDatato use.fixedScheme- the configured fixed scheme asString, ornullif none is set.fixedAuthority- the configured fixed authority asString, ornullif none is set.includeUserInfo-trueif 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:
IllegalArgumentException- iffixedSchemeis notnulland is nothttpnorhttps.
-
getBaseRequestUri
public static String getBaseRequestUri(ConnectionContext ctx, HttpRequestMetaData metaData, boolean includeUserInfo) Get the base URI for the providedConnectionContextandHttpRequestMetaData.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- theConnectionContextto use.metaData- theHttpRequestMetaDatato use.includeUserInfo-trueif 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 String getBaseRequestUri(ConnectionContext ctx, HttpRequestMetaData metaData, @Nullable String fixedScheme, @Nullable String fixedAuthority, boolean includeUserInfo) Get the base URI for the providedConnectionContextandHttpRequestMetaData.For example, for this origin-form request:
GET /pub/WWW/TheProject.html HTTP/1.1 Host: www.example.org:8080
and afixedAuthorityof"example.com"the base request URI will be:http://example.com/
- Parameters:
ctx- theConnectionContextto use.metaData- theHttpRequestMetaDatato use.fixedScheme- the configured fixed scheme asString, ornullif none is set.fixedAuthority- the configured fixed authority asString, ornullif none is set.includeUserInfo-trueif 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:
IllegalArgumentException- iffixedSchemeis notnulland is nothttpnorhttps.
-