Package org.forgerock.http.protocol
Class Request
- java.lang.Object
-
- org.forgerock.http.protocol.MessageImpl<Request>
-
- org.forgerock.http.protocol.Request
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Message<Request>
public final class Request extends MessageImpl<Request>
A request message.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description RequestCookies
getCookies()
Returns the incoming request cookies.Form
getForm()
Deprecated.UsegetQueryParams()
orEntity.getForm()
String
getMethod()
Returns the method to be performed on the resource.Form
getQueryParams()
Returns a copy of the query parameters decoded as a form.MutableUri
getUri()
Returns the fully-qualified URI of the resource being accessed.LazySupplier<Request,IOException>
lazyCopy()
Returns aSupplier
that will lazily copy the request object the first time it is accessed.Request
setEntity(Object o)
Sets the content of the entity to the provided value.Request
setMethod(String method)
Sets the method to be performed on the resource.Request
setUri(String uri)
Sets the fully-qualified string URI of the resource being accessed.Request
setUri(URI uri)
Sets the fully-qualified URI of the resource being accessed.Request
setVersion(String version)
Sets the protocol version.-
Methods inherited from class org.forgerock.http.protocol.MessageImpl
addHeaders, close, getEntity, getHeaders, getVersion, modifyHeaders, putHeaders
-
-
-
-
Constructor Detail
-
Request
public Request()
Creates a new request message.
-
Request
public Request(Request request) throws IOException
Creates a defensive copy of the givenrequest
message.- Parameters:
request
- request to be copied- Throws:
IOException
- when entity cannot be cloned
-
-
Method Detail
-
getCookies
public RequestCookies getCookies()
Returns the incoming request cookies.- Returns:
- The incoming request cookies.
-
getForm
@Deprecated(since="26.1.0") public Form getForm()
Deprecated.UsegetQueryParams()
orEntity.getForm()
Returns a copy of the query parameters and "application/x-www-form-urlencoded" entity decoded as a form. Modifications to the returned form are not reflected in this request.Prefer to use either
getQueryParams()
(if you need to read query parameters only) orEntity.getForm()
(if you need to read form params that come from the entity).- Returns:
- The query parameters and "application/x-www-form-urlencoded" entity as a form.
- See Also:
getQueryParams()
,Entity.getForm()
-
getQueryParams
public Form getQueryParams()
Returns a copy of the query parameters decoded as a form. Modifications to the returned form are not reflected in this request.- Returns:
- The query parameters as a form.
-
getMethod
public String getMethod()
Returns the method to be performed on the resource.- Returns:
- The method to be performed on the resource.
-
getUri
public MutableUri getUri()
Returns the fully-qualified URI of the resource being accessed.- Returns:
- The fully-qualified URI of the resource being accessed.
-
setEntity
public Request setEntity(Object o)
Description copied from interface:Message
Sets the content of the entity to the provided value. Calling this method will close any existing streams associated with the entity. May also set theContent-Length
header, overwriting any existing header.This method is intended mostly as a convenience method within scripts. The parameter will be handled depending on its type as follows:
BranchingInputStream
- equivalent to callingEntity.setRawContentInputStream(org.forgerock.http.io.BranchingInputStream)
byte[]
- equivalent to callingEntity.setBytes(byte[])
String
- equivalent to callingEntity.setString(java.lang.String)
Object
- equivalent to callingEntity.setJson(java.lang.Object)
.
Note: This method does not attempt to encode the entity based-on any codings specified in the
Content-Encoding
header.- Parameters:
o
- The object whose value should be stored in the entity.- Returns:
- This message.
-
setMethod
public Request setMethod(String method)
Sets the method to be performed on the resource.- Parameters:
method
- The method to be performed on the resource.- Returns:
- This request.
-
setUri
public Request setUri(String uri) throws URISyntaxException
Sets the fully-qualified string URI of the resource being accessed.- Parameters:
uri
- The fully-qualified string URI of the resource being accessed.- Returns:
- This request.
- Throws:
URISyntaxException
- if the given URI string is not well-formed.
-
setUri
public Request setUri(URI uri)
Sets the fully-qualified URI of the resource being accessed.- Parameters:
uri
- The fully-qualified URI of the resource being accessed.- Returns:
- This request.
-
setVersion
public Request setVersion(String version)
Description copied from interface:Message
Sets the protocol version. Default:HTTP/1.1
.- Parameters:
version
- The protocol version.- Returns:
- This message.
-
lazyCopy
public LazySupplier<Request,IOException> lazyCopy()
Returns aSupplier
that will lazily copy the request object the first time it is accessed. The same copied request object will be returned on subsequent calls toSupplier.get()
. The returned supplier is thread-safe.- Returns:
- a supplier for the copied request object.
-
-