Package org.eclipse.jetty.http
Class HttpURI
- java.lang.Object
-
- org.eclipse.jetty.http.HttpURI
-
public class HttpURI extends Object
Http URI. Parse a HTTP URI from a string or byte array. Given a URIhttp://user@host:port/path/info;param?query#fragmentthis class will split it into the following undecoded optional elements:getScheme()- http:getAuthority()- //name@host:portgetHost()- hostgetPort()- portgetPath()- /path/infogetParam()- paramgetQuery()- querygetFragment()- fragment
Any parameters will be returned from
getPath(), but are excluded from the return value ofgetDecodedPath(). If there are multiple parameters, thegetParam()method returns only the last one.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclear()static HttpURIcreateHttpURI(String scheme, String host, int port, String path, String param, String query, String fragment)Construct a normalized URI.voiddecodeQueryTo(org.eclipse.jetty.util.MultiMap<String> parameters)voiddecodeQueryTo(org.eclipse.jetty.util.MultiMap<String> parameters, String encoding)voiddecodeQueryTo(org.eclipse.jetty.util.MultiMap<String> parameters, Charset encoding)booleanequals(Object o)StringgetAuthority()StringgetDecodedPath()StringgetFragment()StringgetHost()StringgetParam()StringgetPath()The parsed Path.StringgetPathQuery()intgetPort()StringgetQuery()StringgetScheme()StringgetUser()booleanhasQuery()booleanisAbsolute()voidparse(String uri)voidparse(String uri, int offset, int length)voidparseConnect(String uri)Deprecated.voidparseRequestTarget(String method, String uri)Parse according to https://tools.ietf.org/html/rfc7230#section-5.3voidsetAuthority(String host, int port)voidsetPath(String path)voidsetPathQuery(String path)voidsetQuery(String query)voidsetScheme(String scheme)StringtoString()URItoURI()
-
-
-
Method Detail
-
createHttpURI
public static HttpURI createHttpURI(String scheme, String host, int port, String path, String param, String query, String fragment)
Construct a normalized URI. Port is not set if it is the default port.- Parameters:
scheme- the URI schemehost- the URI hoseport- the URI portpath- the URI pathparam- the URI paramquery- the URI queryfragment- the URI fragment- Returns:
- the normalized URI
-
parse
public void parse(String uri)
-
parseRequestTarget
public void parseRequestTarget(String method, String uri)
Parse according to https://tools.ietf.org/html/rfc7230#section-5.3- Parameters:
method- the request methoduri- the request uri
-
parseConnect
@Deprecated public void parseConnect(String uri)
Deprecated.
-
parse
public void parse(String uri, int offset, int length)
-
getScheme
public String getScheme()
-
getHost
public String getHost()
-
getPort
public int getPort()
-
getPath
public String getPath()
The parsed Path.- Returns:
- the path as parsed on valid URI. null for invalid URI.
-
getDecodedPath
public String getDecodedPath()
-
getParam
public String getParam()
-
getQuery
public String getQuery()
-
hasQuery
public boolean hasQuery()
-
getFragment
public String getFragment()
-
decodeQueryTo
public void decodeQueryTo(org.eclipse.jetty.util.MultiMap<String> parameters)
-
decodeQueryTo
public void decodeQueryTo(org.eclipse.jetty.util.MultiMap<String> parameters, String encoding) throws UnsupportedEncodingException
- Throws:
UnsupportedEncodingException
-
decodeQueryTo
public void decodeQueryTo(org.eclipse.jetty.util.MultiMap<String> parameters, Charset encoding) throws UnsupportedEncodingException
- Throws:
UnsupportedEncodingException
-
clear
public void clear()
-
isAbsolute
public boolean isAbsolute()
-
setScheme
public void setScheme(String scheme)
-
setAuthority
public void setAuthority(String host, int port)
- Parameters:
host- the hostport- the port
-
setPath
public void setPath(String path)
- Parameters:
path- the path
-
setPathQuery
public void setPathQuery(String path)
-
setQuery
public void setQuery(String query)
-
toURI
public URI toURI() throws URISyntaxException
- Throws:
URISyntaxException
-
getPathQuery
public String getPathQuery()
-
getAuthority
public String getAuthority()
-
getUser
public String getUser()
-
-