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.Pathmust be normalized at all times.- Only
HttpURL.Queryis allowed, in addition to the above.
-
It contains all those helpful builder methods that
URIhas none of.HttpURL.Pathcan be parsed, have segments or other paths appended, and cut.HttpURL.Querycan be parsed, and keys and key-value pairs can be inserted or removed.
- It makes it super-easy to use a
StringWrapperfor validation of path and query segments.
- Author:
- jonmv
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic 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 HttpURLcreate(HttpURL.Scheme scheme, DomainName domain) static HttpURLcreate(HttpURL.Scheme scheme, DomainName domain, int port) static HttpURLcreate(HttpURL.Scheme scheme, DomainName domain, int port, HttpURL.Path path) static HttpURLcreate(HttpURL.Scheme scheme, DomainName domain, int port, HttpURL.Path path, HttpURL.Query query) domain()booleanstatic HttpURLstatic HttpURLinthashCode()path()port()query()static StringrequirePathSegment(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"", ".", "..".
-