Package org.forgerock.http.protocol
Class Request
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Message<Request>
A request message.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the incoming request cookies.getForm()
Deprecated.Returns the method to be performed on the resource.Returns a copy of the query parameters decoded as a form.getUri()
Returns the fully-qualified URI of the resource being accessed.lazyCopy()
Returns aSupplier
that will lazily copy the request object the first time it is accessed.Sets the content of the entity to the provided value.Sets the method to be performed on the resource.Sets the fully-qualified string URI of the resource being accessed.Sets the fully-qualified URI of the resource being accessed.setVersion
(String version) Sets the protocol version.Methods inherited from class org.forgerock.http.protocol.MessageImpl
addHeaders, close, getEntity, getHeaders, getVersion, modifyHeaders, putHeaders
-
Constructor Details
-
Request
public Request()Creates a new request message. -
Request
Creates a defensive copy of the givenrequest
message.- Parameters:
request
- request to be copied- Throws:
IOException
- when entity cannot be cloned
-
-
Method Details
-
getCookies
Returns the incoming request cookies.- Returns:
- The incoming request cookies.
-
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
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
Returns the method to be performed on the resource.- Returns:
- The method to be performed on the resource.
-
getUri
Returns the fully-qualified URI of the resource being accessed.- Returns:
- The fully-qualified URI of the resource being accessed.
-
setEntity
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
Sets the method to be performed on the resource.- Parameters:
method
- The method to be performed on the resource.- Returns:
- This request.
-
setUri
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
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
Description copied from interface:Message
Sets the protocol version. Default:HTTP/1.1
.- Parameters:
version
- The protocol version.- Returns:
- This message.
-
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.
-
getQueryParams()
orEntity.getForm()