public class BasicHttpRequest extends HeaderGroup implements HttpRequest
HttpRequest
.Constructor and Description |
---|
BasicHttpRequest(Method method,
HttpHost host,
String path)
Creates request message with the given method, host and request path.
|
BasicHttpRequest(Method method,
String path)
Creates request message with the given method and request path.
|
BasicHttpRequest(Method method,
URI requestUri)
Creates request message with the given method, request URI.
|
BasicHttpRequest(String method,
HttpHost host,
String path)
Creates request message with the given method, host and request path.
|
BasicHttpRequest(String method,
String path)
Creates request message with the given method and request path.
|
BasicHttpRequest(String method,
String scheme,
URIAuthority authority,
String path)
Creates request message with the given method, host and request path.
|
BasicHttpRequest(String method,
URI requestUri)
Creates request message with the given method, request URI.
|
Modifier and Type | Method and Description |
---|---|
void |
addHeader(String name,
Object value)
Adds a header to this message.
|
URIAuthority |
getAuthority()
Returns authority of this request message.
|
String |
getMethod()
Returns method of this request message.
|
String |
getPath()
Returns URI path of this request message or
null if not set. |
String |
getRequestUri()
Returns request URI of this request message.
|
String |
getScheme()
Returns scheme of this request message.
|
URI |
getUri()
Returns full request URI of this request message.
|
ProtocolVersion |
getVersion()
Returns protocol version or
null when not available. |
void |
setAbsoluteRequestUri(boolean absoluteRequestUri)
Sets whether
getRequestUri() should return the request URI in an absolute form. |
void |
setAuthority(URIAuthority authority)
Sets authority of this request message.
|
void |
setHeader(String name,
Object value)
Overwrites the first header with the same name.
|
void |
setPath(String path)
Sets URI path of this request message.
|
void |
setScheme(String scheme)
Sets scheme of this request message.
|
void |
setUri(URI requestUri)
Sets the full request URI of this request message.
|
void |
setVersion(ProtocolVersion version)
Sets protocol version.
|
String |
toString() |
addHeader, clear, containsHeader, countHeaders, getCondensedHeader, getFirstHeader, getHeader, getHeaders, getHeaders, getLastHeader, headerIterator, headerIterator, removeHeader, removeHeaders, removeHeaders, setHeader, setHeaders
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addHeader, removeHeader, removeHeaders, setHeader, setHeaders
containsHeader, countHeaders, getFirstHeader, getHeader, getHeaders, getHeaders, getLastHeader, headerIterator, headerIterator
public BasicHttpRequest(String method, String scheme, URIAuthority authority, String path)
method
- request method.scheme
- request scheme.authority
- request authority.path
- request path.public BasicHttpRequest(String method, String path)
method
- request method.path
- request path.public BasicHttpRequest(String method, HttpHost host, String path)
method
- request method.host
- request host.path
- request path.public BasicHttpRequest(String method, URI requestUri)
method
- request method.requestUri
- request URI.public BasicHttpRequest(Method method, String path)
method
- request method.path
- request path.public BasicHttpRequest(Method method, HttpHost host, String path)
method
- request method.host
- request host.path
- request path.public void addHeader(String name, Object value)
HttpMessage
addHeader
in interface HttpMessage
name
- the name of the header.value
- the value of the header, taken as the value's Object.toString()
.public void setHeader(String name, Object value)
HttpMessage
setHeader
in interface HttpMessage
name
- the name of the header.value
- the value of the header, taken as the value's Object.toString()
.public void setVersion(ProtocolVersion version)
HttpMessage
For incoming messages it represents protocol version this message was transmitted with. For outgoing messages it represents a hint what protocol version should be used to transmit the message.
setVersion
in interface HttpMessage
version
- The protocol version.public ProtocolVersion getVersion()
HttpMessage
null
when not available.
For incoming messages it represents protocol version this message was transmitted with. For outgoing messages it represents a hint what protocol version should be used to transmit the message.
getVersion
in interface HttpMessage
public String getMethod()
HttpRequest
getMethod
in interface HttpRequest
public String getPath()
HttpRequest
null
if not set.getPath
in interface HttpRequest
null
.public void setPath(String path)
HttpRequest
setPath
in interface HttpRequest
path
- The URI path of this request message.public String getScheme()
HttpRequest
getScheme
in interface HttpRequest
null
.public void setScheme(String scheme)
HttpRequest
setScheme
in interface HttpRequest
scheme
- The scheme of this request message.public URIAuthority getAuthority()
HttpRequest
getAuthority
in interface HttpRequest
null
.public void setAuthority(URIAuthority authority)
HttpRequest
setAuthority
in interface HttpRequest
authority
- The authority of this request message.public void setAbsoluteRequestUri(boolean absoluteRequestUri)
getRequestUri()
should return the request URI in an absolute form.
This flag can used when the request is going to be transmitted via an HTTP/1.1 proxy.
absoluteRequestUri
- Whether getRequestUri()
should return the request URI in an absolute form.public String getRequestUri()
HttpRequest
getRequestUri
in interface HttpRequest
public void setUri(URI requestUri)
HttpRequest
setUri
in interface HttpRequest
requestUri
- the request URI.public URI getUri() throws URISyntaxException
HttpRequest
getUri
in interface HttpRequest
URISyntaxException
- Thrown when a string could not be parsed as a URI reference.public String toString()
toString
in class HeaderGroup
Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.