Package org.apache.hc.core5.http.message
Class BasicHttpRequest
java.lang.Object
org.apache.hc.core5.http.message.HeaderGroup
org.apache.hc.core5.http.message.BasicHttpRequest
- All Implemented Interfaces:
Serializable
,HttpMessage
,HttpRequest
,MessageHeaders
- Direct Known Subclasses:
BasicClassicHttpRequest
Basic implementation of
HttpRequest
.- Since:
- 4.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private URIAuthority
private final String
private String
private URI
private String
private static final long
private ProtocolVersion
-
Constructor Summary
ConstructorsConstructorDescriptionBasicHttpRequest
(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.BasicHttpRequest
(String 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
(Method method, HttpHost host, String path) Creates request message with the given method, host and request path. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a header to this message.private void
Returns authority of this request message.Returns method of this request message.getPath()
Returns URI path of this request message ornull
if not set.Returns request URI of this request message.Returns scheme of this request message.getUri()
Returns full request URI of this request message.Returns protocol version ornull
when not available.void
setAbsoluteRequestUri
(boolean absoluteRequestUri) Sets a flag that thegetRequestUri()
method should return the request URI in an absolute form.void
setAuthority
(URIAuthority authority) Sets authority of this request message.void
Overwrites the first header with the same name.void
Sets URI path of this request message.void
Sets scheme of this request message.void
Sets the full request URI of this request message.void
setVersion
(ProtocolVersion version) Sets protocol version.toString()
Methods inherited from class org.apache.hc.core5.http.message.HeaderGroup
addHeader, clear, containsHeader, countHeaders, getCondensedHeader, getFirstHeader, getHeader, getHeaders, getHeaders, getLastHeader, headerIterator, headerIterator, removeHeader, removeHeaders, removeHeaders, setHeader, setHeaders
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.hc.core5.http.HttpMessage
addHeader, removeHeader, removeHeaders, setHeader, setHeaders
Methods inherited from interface org.apache.hc.core5.http.MessageHeaders
containsHeader, countHeaders, getFirstHeader, getHeader, getHeaders, getHeaders, getLastHeader, headerIterator, headerIterator
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
method
-
path
-
scheme
-
authority
-
version
-
requestUri
-
absoluteRequestUri
private boolean absoluteRequestUri
-
-
Constructor Details
-
BasicHttpRequest
Creates request message with the given method, host and request path.- Parameters:
method
- request method.scheme
- request scheme.authority
- request authority.path
- request path.- Since:
- 5.1
-
BasicHttpRequest
Creates request message with the given method and request path.- Parameters:
method
- request method.path
- request path.
-
BasicHttpRequest
Creates request message with the given method, host and request path.- Parameters:
method
- request method.host
- request host.path
- request path.- Since:
- 5.0
-
BasicHttpRequest
Creates request message with the given method, request URI.- Parameters:
method
- request method.requestUri
- request URI.- Since:
- 5.0
-
BasicHttpRequest
Creates request message with the given method and request path.- Parameters:
method
- request method.path
- request path.- Since:
- 5.0
-
BasicHttpRequest
Creates request message with the given method, host and request path.- Parameters:
method
- request method.host
- request host.path
- request path.- Since:
- 5.0
-
BasicHttpRequest
Creates request message with the given method, request URI.- Parameters:
method
- request method.requestUri
- request URI.- Since:
- 5.0
-
-
Method Details
-
addHeader
Description copied from interface:HttpMessage
Adds a header to this message. The header will be appended to the end of the list.- Specified by:
addHeader
in interfaceHttpMessage
- Parameters:
name
- the name of the header.value
- the value of the header, taken as the value'sObject.toString()
.
-
setHeader
Description copied from interface:HttpMessage
Overwrites the first header with the same name. The new header will be appended to the end of the list, if no header with the given name can be found.- Specified by:
setHeader
in interfaceHttpMessage
- Parameters:
name
- the name of the header.value
- the value of the header, taken as the value'sObject.toString()
.
-
setVersion
Description copied from interface:HttpMessage
Sets protocol version.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.
- Specified by:
setVersion
in interfaceHttpMessage
-
getVersion
Description copied from interface:HttpMessage
Returns protocol version ornull
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.
- Specified by:
getVersion
in interfaceHttpMessage
-
getMethod
Description copied from interface:HttpRequest
Returns method of this request message.- Specified by:
getMethod
in interfaceHttpRequest
- Returns:
- the request method.
-
getPath
Description copied from interface:HttpRequest
Returns URI path of this request message ornull
if not set.- Specified by:
getPath
in interfaceHttpRequest
- Returns:
- the request URI or
null
.
-
setPath
Description copied from interface:HttpRequest
Sets URI path of this request message.- Specified by:
setPath
in interfaceHttpRequest
-
getScheme
Description copied from interface:HttpRequest
Returns scheme of this request message.- Specified by:
getScheme
in interfaceHttpRequest
- Returns:
- the scheme or
null
.
-
setScheme
Description copied from interface:HttpRequest
Sets scheme of this request message.- Specified by:
setScheme
in interfaceHttpRequest
-
getAuthority
Description copied from interface:HttpRequest
Returns authority of this request message.- Specified by:
getAuthority
in interfaceHttpRequest
- Returns:
- the authority or
null
.
-
setAuthority
Description copied from interface:HttpRequest
Sets authority of this request message.- Specified by:
setAuthority
in interfaceHttpRequest
-
setAbsoluteRequestUri
public void setAbsoluteRequestUri(boolean absoluteRequestUri) Sets a flag that thegetRequestUri()
method 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.
- Since:
- 5.1
-
getRequestUri
Description copied from interface:HttpRequest
Returns request URI of this request message. It may be an absolute or relative URI. Applicable to HTTP/1.1 version or earlier.- Specified by:
getRequestUri
in interfaceHttpRequest
- Returns:
- the request URI.
-
setUri
Description copied from interface:HttpRequest
Sets the full request URI of this request message.- Specified by:
setUri
in interfaceHttpRequest
- Parameters:
requestUri
- the request URI.
-
assembleRequestUri
-
getUri
Description copied from interface:HttpRequest
Returns full request URI of this request message.- Specified by:
getUri
in interfaceHttpRequest
- Returns:
- the request URI.
- Throws:
URISyntaxException
-
toString
- Overrides:
toString
in classHeaderGroup
-