Object -
http :
Request
Represents an HTTP request.
Methods
Sets the provided Entity
to the request.
Gets the query parameters of the request, as a map.
Gets the matrix parameters of the request.
Gets the Entity
associated with the request.
Checks whether the requested header key exists in the header map.
Returns the value of the specified header. If the specified header key maps to multiple values, the first of these values is returned.
Gets all the header values to which the specified header key maps to.
Sets the specified header to the request. If a mapping already exists for the specified header key, the existing header value is replaced with the specified header value.
Adds the specified header to the request. Existing header values are not replaced.
Removes the specified header from the request.
Removes all the headers from the request.
Gets all the names of the headers of the request.
Checks whether the client expects a 100-continue
response.
Sets the content-type
header to the request.
Gets the type of the payload of the request (i.e: the content-type
header value).
Extracts json
payload from the request. If the content type is not JSON, an error
is returned.
Extracts xml
payload from the request. If the content type is not XML, an error
is returned.
Extracts text
payload from the request. If the content type is not of type text, an error
is returned.
Gets the request payload as a ByteChannel
except in the case of multiparts. To retrieve multiparts, use
getBodyParts()
.
Gets the request payload as a byte[]
.
Gets the form parameters from the HTTP request as a map
when content type is application/x-www-form-urlencoded.
Extracts body parts from the request. If the content type is not a composite media type, an error is returned.
Sets a json
as the payload.
Sets an xml
as the payload.
Sets a string
as the payload.
Sets a byte[]
as the payload.
Set multiparts as the payload.
Sets the content of the specified file as the entity body of the request.
Sets a ByteChannel
as the payload.
Sets the request payload.
Fields
- rawPath string
-
Resource path of the request URL
- method string
-
The HTTP request method
- httpVersion string
-
The HTTP version supported by the client
- userAgent string
-
The user-agent. This value is used when setting the
user-agent
header
- extraPathInfo string
-
Additional information associated with the URL provided by the client
- cacheControl RequestCacheControl? ()
-
The cache-control directives for the request. This needs to be explicitly initialized if intending on utilizing HTTP caching.
- mutualSslHandshake MutualSslHandshake? ()
-
A record providing mutual ssl handshake results.
Sets the provided Entity
to the request.
Parameters
- e Entity
-
The
Entity
to be set to the request
Gets the query parameters of the request, as a map.
-
Return Type
(map) String map of query params
Gets the matrix parameters of the request.
Parameters
- path string
-
Path to the location of matrix parameters
-
Return Type
(map) A map of matrix parameters which can be found for the given path
Gets the Entity
associated with the request.
Checks whether the requested header key exists in the header map.
Parameters
- headerName string
-
The header name
-
Return Type
(boolean) Returns true if the specified header key exists
Returns the value of the specified header. If the specified header key maps to multiple values, the first of these values is returned.
Parameters
- headerName string
-
The header name
-
Return Type
(string) The first header value for the specified header name. An exception is thrown if no header is found. Use
hasHeader()
beforehand to check the existence of header.
Gets all the header values to which the specified header key maps to.
Parameters
- headerName string
-
The header name
-
Return Type
(string[]) The header values the specified header key maps to. An exception is thrown if no header is found. Use
hasHeader()
beforehand to check the existence of header.
Sets the specified header to the request. If a mapping already exists for the specified header key, the existing header value is replaced with the specified header value.
Adds the specified header to the request. Existing header values are not replaced.
Gets all the names of the headers of the request.
-
Return Type
(string[]) An array of all the header names
Checks whether the client expects a 100-continue
response.
-
Return Type
(boolean) Returns true if the client expects a
100-continue
response
Sets the content-type
header to the request.
Parameters
- contentType string
-
Content type value to be set as the
content-type
header
-
Return Type
(error?) Nil if successful, error in case of invalid content-type
Gets the type of the payload of the request (i.e: the content-type
header value).
-
Return Type
(string) Returns the
content-type
header value as a string
Extracts json
payload from the request. If the content type is not JSON, an error
is returned.
Extracts xml
payload from the request. If the content type is not XML, an error
is returned.
Extracts text
payload from the request. If the content type is not of type text, an error
is returned.
Gets the request payload as a ByteChannel
except in the case of multiparts. To retrieve multiparts, use
getBodyParts()
.
-
Return Type
(ReadableByteChannel | error) A byte channel from which the message payload can be read or
error
in case of errors
Gets the request payload as a byte[]
.
Gets the form parameters from the HTTP request as a map
when content type is application/x-www-form-urlencoded.
Extracts body parts from the request. If the content type is not a composite media type, an error is returned.
Sets a json
as the payload.
Sets an xml
as the payload.
Sets a string
as the payload.
Sets a byte[]
as the payload.
Set multiparts as the payload.
Sets the content of the specified file as the entity body of the request.
Sets a ByteChannel
as the payload.
Parameters
- payload ReadableByteChannel
-
A
ByteChannel
through which the message payload can be read
- contentType string - application/octet-stream
-
The content type of the payload. Set this to override the default
content-type
header value