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 consisting of a string array.
Gets the query param value associated with the given key.
Gets all the query param values associated with the given key.
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.
Gets all the header values to which the specified header key maps to.
Sets the specified header to the request.
Adds the specified header to the request.
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.
Extracts json payload from the request.
Extracts xml payload from the request.
Extracts text payload from the request.
Gets the request payload as a ByteChannel except in the case of multiparts.
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.
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.
Adds cookies to the request.
Gets cookies from the request.
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-agentheader
- extraPathInfo string
-
The part of the URL, which matched to '*' if the request is dispatched to a wildcard resource
- cacheControl RequestCacheControl? (default ())
-
The cache-control directives for the request. This needs to be explicitly initialized if intending on utilizing HTTP caching.
- mutualSslHandshake MutualSslHandshake? (default ())
-
A record providing mutual ssl handshake results.
Sets the provided Entity to the request.
Parameters
- e Entity
-
The
Entityto be set to the request
Gets the query parameters of the request as a map consisting of a string array.
-
Return Type
(map<string[]>) String array map of the query params
Gets the query param value associated with the given key.
Parameters
- key string
-
Represents the query param key
-
Return Type
(string?) The query param value associated with the given key as a string. If multiple param values are present, then the first value is returned.
()is returned if no key is found.
Gets all the query param values associated with the given key.
Parameters
- key string
-
Represents the query param key
-
Return Type
(string[]?) All the query param values associated with the given key as a
string[].()is returned if no key is found.
Gets the matrix parameters of the request.
Parameters
- path string
-
Path to the location of matrix parameters
-
Return Type
(map<any>) A map of matrix parameters which can be found for the given path
Gets the Entity associated with the request.
-
Return Type
(Entity | ClientError) The
Entityof the request. Anhttp:ClientErroris returned, if entity construction fails
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. Panic if the header is not found. Use the
Request.hasHeader()beforehand to check the existence of a 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. Panic if the header is not found. Use the
Request.hasHeader()beforehand to check the existence of a 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. Panic if an illegal header is passed.
Parameters
- headerName string
-
The header name
- headerValue string
-
The header value
Adds the specified header to the request. Existing header values are not replaced. Panic if an illegal header is passed.
Parameters
- headerName string
-
The header name
- headerValue string
-
The header value
Removes the specified header from the request.
Parameters
- key string
-
The header name
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-continueresponse
Sets the content-type header to the request.
Parameters
- contentType string
-
Content type value to be set as the
content-typeheader
-
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) The
content-typeheader value as a string
Extracts json payload from the request. If the content type is not JSON, an http:ClientError is returned.
-
Return Type
(json | ClientError) The
jsonpayload orhttp:ClientErrorin case of errors
Extracts xml payload from the request. If the content type is not XML, an http:ClientError is returned.
-
Return Type
(xml | ClientError) The
xmlpayload orhttp:ClientErrorin case of errors
Extracts text payload from the request. If the content type is not of type text, an http:ClientError is returned.
-
Return Type
(string | ClientError) The
textpayload orhttp:ClientErrorin case of errors
Gets the request payload as a ByteChannel except in the case of multiparts. To retrieve multiparts, use
Request.getBodyParts().
-
Return Type
(ReadableByteChannel | ClientError) A byte channel from which the message payload can be read or
http:ClientErrorin case of errors
Gets the request payload as a byte[].
-
Return Type
(byte[] | ClientError) The byte[] representation of the message payload or
http:ClientErrorin case of errors
Gets the form parameters from the HTTP request as a map when content type is application/x-www-form-urlencoded.
-
Return Type
(map<string> | ClientError) The map of form params or
http:ClientErrorin case of errors
Extracts body parts from the request. If the content type is not a composite media type, an error is returned.
-
Return Type
(Entity[] | ClientError) The body parts as an array of entities or else an
http:ClientErrorif there were any errors constructing the body parts from the request
Sets a json as the payload.
Parameters
- payload json
-
The
jsonpayload
- contentType string (default application/json)
-
The content type of the payload. Set this to override the default
content-typeheader value forjson
Sets an xml as the payload.
Parameters
- payload xml
-
The
xmlpayload
- contentType string (default application/xml)
-
The content type of the payload. Set this to override the default
content-typeheader value forxml
Sets a string as the payload.
Parameters
- payload string
-
The
stringpayload
- contentType string (default text/plain)
-
The content type of the payload. Set this to override the default
content-typeheader value forstring
Sets a byte[] as the payload.
Parameters
- payload byte[]
-
The
byte[]payload
- contentType string (default application/octet-stream)
-
The content type of the payload. Set this to override the default
content-typeheader value forbyte[]
Set multiparts as the payload.
Parameters
- bodyParts Entity[]
-
The entities which make up the message body
- contentType string (default multipart/form-data)
-
The content type of the top level message. Set this to override the default
content-typeheader value
Sets the content of the specified file as the entity body of the request.
Parameters
- filePath string
-
Path to the file to be set as the payload
- contentType string (default application/octet-stream)
-
The content type of the specified file. Set this to override the default
content-typeheader value
Sets a ByteChannel as the payload.
Parameters
- payload ReadableByteChannel
-
A
ByteChannelthrough which the message payload can be read
- contentType string (default application/octet-stream)
-
The content type of the payload. Set this to override the default
content-typeheader value
Sets the request payload. Note that any string value is set as text/plain. To send a JSON-compatible string,
set the content-type header to application/json or use the setJsonPayload method instead.
Parameters
- payload string | xml | json | byte[] | ReadableByteChannel | Entity[]
-
Payload can be of type
string,xml,json,byte[],ByteChannel, orEntity[](i.e., a set of body parts).
Adds cookies to the request.
Parameters
- cookiesToAdd Cookie[]
-
Represents the cookies to be added