Package org.wiremock.url
Interface Origin
- All Superinterfaces:
AbsoluteUri,AbsoluteUrl,BaseUrl,Normalisable<AbsoluteUri>,org.wiremock.stringparser.ParsedString,ServersideAbsoluteUrl,Uri,Url,UrlWithAuthority
Represents a web origin as defined in HTML Living
Standard.
An origin consists of a scheme, host, and port. It represents the security context of a web resource and is used for same-origin policy enforcement. Origins have no path, query, or fragment components.
The component parts of an origin (scheme, host and port) are always normalised. The origin
itself is not the normal form of the URL it represents, since it has an empty path rather
than an absolute root path. Origin.parse("https://example.org").normalise().toString()
will return https://example.org/ .
Implementations must be immutable and thread-safe.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.wiremock.url.AbsoluteUrl
AbsoluteUrl.Builder, AbsoluteUrl.Transformer -
Method Summary
Modifier and TypeMethodDescriptionReturns the authority component of this origin.default OriginDeprecated.default PathgetPath()Deprecated.This always returns empty so you have no reason to ever call itdefault PathAndQueryDeprecated.This always returns empty so you have no reason to ever call itdefault @Nullable QuerygetQuery()Deprecated.This always returns null so you have no reason to ever call itdefault OriginDeprecated.Returns a normalised form of this origin by setting the path to/.static Originof(Scheme scheme, HostAndPort hostAndPort) Creates an origin from a scheme and host/port.static OriginParses a string into an origin.Methods inherited from interface org.wiremock.url.AbsoluteUri
getScheme, isAbsolute, isNormalForm, resolve, resolveMethods inherited from interface org.wiremock.url.AbsoluteUrl
getHost, getSchemeRelativeUrl, isAbsoluteUrl, isOpaqueUri, isRelative, resolve, resolve, resolve, thaw, transformMethods inherited from interface org.wiremock.stringparser.ParsedString
toStringMethods inherited from interface org.wiremock.url.ServersideAbsoluteUrl
getFragmentMethods inherited from interface org.wiremock.url.Uri
getPort, getQueryOrEmpty, getResolvedPort, getUserInfo, toJavaUri
-
Method Details
-
getAuthority
HostAndPort getAuthority()Returns the authority component of this origin.Origins always have an authority that is a
HostAndPort(no user info).- Specified by:
getAuthorityin interfaceAbsoluteUrl- Specified by:
getAuthorityin interfaceUri- Specified by:
getAuthorityin interfaceUrlWithAuthority- Returns:
- the authority component, never
null
-
getPathAndQuery
Deprecated.This always returns empty so you have no reason to ever call itImplementations must ALWAYS returnPathAndQuery.EMPTY- Specified by:
getPathAndQueryin interfaceUrl- Returns:
PathAndQuery.EMPTY
-
getPath
Deprecated.This always returns empty so you have no reason to ever call itImplementations must ALWAYS returnPath.EMPTY- Specified by:
getPathin interfaceUri- Returns:
Path.EMPTY
-
getQuery
Deprecated.This always returns null so you have no reason to ever call itImplementations must ALWAYS return null -
normalise
BaseUrl normalise()Returns a normalised form of this origin by setting the path to/.- Specified by:
normalisein interfaceAbsoluteUri- Specified by:
normalisein interfaceAbsoluteUrl- Specified by:
normalisein interfaceBaseUrl- Specified by:
normalisein interfaceNormalisable<AbsoluteUri>- Specified by:
normalisein interfaceServersideAbsoluteUrl- Returns:
- a normalised origin (as a URL)
-
getOrigin
Deprecated.Returns this.- Specified by:
getOriginin interfaceAbsoluteUrl- Returns:
- this
-
getServersideAbsoluteUrl
Deprecated.Returns this.- Specified by:
getServersideAbsoluteUrlin interfaceAbsoluteUrl- Specified by:
getServersideAbsoluteUrlin interfaceBaseUrl- Specified by:
getServersideAbsoluteUrlin interfaceServersideAbsoluteUrl- Returns:
- this
-
of
Creates an origin from a scheme and host/port.- Parameters:
scheme- the schemehostAndPort- the host and port- Returns:
- the origin
- Throws:
IllegalOrigin- if any of the scheme, host and port are not normalised
-
parse
Parses a string into an origin.- Parameters:
origin- the string to parse- Returns:
- the parsed origin
- Throws:
IllegalOrigin- if the string is not a valid origin
-