Package ai.vespa.http
Class HttpURL
java.lang.Object
ai.vespa.http.HttpURL
This is the best class for creating, manipulating and inspecting HTTP URLs, because:
- It is more restrictive than
URI
, but with a richer construction API, reducing risk of blunder.- Scheme must be HTTP or HTTPS.
- Authority must be a
DomainName
, with an optional port. HttpURL.Path
must be normalized at all times.- Only
HttpURL.Query
is allowed, in addition to the above.
-
It contains all those helpful builder methods that
URI
has none of.HttpURL.Path
can be parsed, have segments or other paths appended, and cut.HttpURL.Query
can be parsed, and keys and key-value pairs can be inserted or removed.
- It makes it super-easy to use a
StringWrapper
for validation of path and query segments.
- Author:
- jonmv
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
static enum
-
Method Summary
Modifier and TypeMethodDescriptionappendPath
(HttpURL.Path path) Returns a copy of this with the given path appended.appendQuery
(HttpURL.Query query) Returns a copy of this with all entries of the query appended.asURI()
Returns an absolute, hierarchical URI representing this HTTP URL.static HttpURL
create
(HttpURL.Scheme scheme, DomainName domain) static HttpURL
create
(HttpURL.Scheme scheme, DomainName domain, int port) static HttpURL
create
(HttpURL.Scheme scheme, DomainName domain, int port, HttpURL.Path path) static HttpURL
create
(HttpURL.Scheme scheme, DomainName domain, int port, HttpURL.Path path, HttpURL.Query query) domain()
boolean
static HttpURL
static HttpURL
int
hashCode()
path()
port()
query()
static String
requirePathSegment
(String value) Require that the given string (possibly decoded multiple times) contains none of'/', '?', '#'
, and isn't either of"", ".", ".."
.scheme()
toString()
withDomain
(DomainName domain) Returns a copy of this with the given domain.Returns a copy of this with no port specified.withPath
(HttpURL.Path path) Returns a copy of this with only the given path.withPort
(int port) Returns a copy of this with the given non-negative port.withQuery
(HttpURL.Query query) Returns a copy of this with only the given query.withScheme
(HttpURL.Scheme scheme) Returns a copy of this with the given scheme.
-
Method Details
-
create
public static HttpURL create(HttpURL.Scheme scheme, DomainName domain, int port, HttpURL.Path path, HttpURL.Query query) -
create
-
create
-
create
-
from
-
from
-
withScheme
Returns a copy of this with the given scheme. -
withDomain
Returns a copy of this with the given domain. -
withPort
Returns a copy of this with the given non-negative port. -
withoutPort
Returns a copy of this with no port specified. -
withPath
Returns a copy of this with only the given path. -
appendPath
Returns a copy of this with the given path appended. -
withQuery
Returns a copy of this with only the given query. -
appendQuery
Returns a copy of this with all entries of the query appended. -
scheme
-
domain
-
port
-
path
-
query
-
asURI
Returns an absolute, hierarchical URI representing this HTTP URL. -
equals
-
hashCode
public int hashCode() -
toString
-
requirePathSegment
Require that the given string (possibly decoded multiple times) contains none of'/', '?', '#'
, and isn't either of"", ".", ".."
.
-