Skip to content

Latest commit

 

History

History
450 lines (280 loc) · 20.4 KB

File metadata and controls

450 lines (280 loc) · 20.4 KB

dw::io::http::Client


HTTP client module allows to make HTTP calls

To use this module, you must import it to your DataWeave code, for example, by adding the line import * from dw::io::http::Client to the header of your DataWeave script.

Index

Functions

Name Description
connect Helper function to send a CONNECT HTTP request.
createAuthorizationHeader Utility function that adds the proper Authorization header based on the supported Auth type.
createBinaryHttpRequest Helper function to create a HttpRequest instances with Binary request body.
createHttpRequest Helper function to create an HttpRequest instance.
delete Helper function to send a DELETE HTTP request.
get Helper function to send a GET HTTP request.
head Helper function to send a HEAD HTTP request.
options Helper function to send a OPTIONS HTTP request.
patch Helper function to send a PATCH HTTP request.
post Helper function to send a POST HTTP request.
postMultipart Helper function to send a multipart HTTP request.
put Helper function to send a PUT HTTP request.
readBody Helper function to read a Binary body instance.
readHttpResponseBody Helper function to read a HttpResponse with a Binary body instance.
resolveTemplateWith Replace the templates of a url according to RFC6570
sendRequest Sends an HTTP request by using the provided binaryRequestEncoder to convert the current request into an HttpRequest<Binary,H&#62; instance
with the desired configurations (request/client configuration) and returns an HTTP response using the provided binaryResponseDecoder to convert
the current HTTP response into an HttpResponse<B, H&#62;> instance.
sendRequestAndReadResponse Sends an HTTP request by writing the request body into a Binary instance and reading
the HTTP response Binary body instance.
trace Helper function to send a TRACE HTTP request.
url String interpolator function to build a URL

Variables

Name Description
DEFAULT_HTTP_CLIENT_CONFIG Variable used to identify the default HTTP client configuration.
DEFAULT_HTTP_REQUEST_CONFIG Variable used to identify the default HTTP request configuration.
DEFAULT_SERIALIZATION_CONFIG Variable used to identify the default HTTP serialization configuration.

Functions

connect

connect<B <: HttpBody, H <: HttpHeaders>(url: String | UrlBuilder, headers: HttpHeaders = {}, requestConfig: HttpRequestConfig = DEFAULT_HTTP_REQUEST_CONFIG, serializationConfig: SerializationConfig = DEFAULT_SERIALIZATION_CONFIG, clientConfig: HttpClientConfig = DEFAULT_HTTP_CLIENT_CONFIG): HttpResponse<B, H>

Helper function to send a CONNECT HTTP request.

Parameters
Name Type Description
url String &#124; UrlBuilder The desired HTTP request url.
headers HttpHeaders The HTTP request header to send.
requestConfig HttpRequestConfig The HTTP request configuration to use.
serializationConfig SerializationConfig The HTTP serialization configuration to use.
clientConfig HttpClientConfig The HTTP client configuration configuration to use.

createAuthorizationHeader

createAuthorizationHeader(kind: OAuth | BasicAuth): {| Authorization: String |}

Utility function that adds the proper Authorization header based on the supported Auth type.


createBinaryHttpRequest

createBinaryHttpRequest(request: HttpRequest, serializationConfig: SerializationConfig): HttpRequest<Binary>

Helper function to create a HttpRequest instances with Binary request body.

Parameters
Name Type Description
request HttpRequest The desired HTTP request to convert to a HttpRequest instances with Binary request body.
serializationConfig SerializationConfig The HTTP serialization configuration to use.

createHttpRequest

createHttpRequest<T <: HttpBody>(method: HttpMethod, url: String | UrlBuilder, headers: HttpHeaders = {}, body: T | Null = null, cookies: HttpRequestCookies = {}): HttpRequest<T>

Helper function to create an HttpRequest instance.

Parameters
Name Type Description
method HttpMethod The desired HTTP request method.
url String &#124; UrlBuilder The desired HTTP request url.
headers HttpHeaders The HTTP request header to send.
cookies HttpRequestCookies The HTTP request cookies to send.
body HttpBody &#124; Null The HTTP request body to send.

delete

delete<B <: HttpBody, H <: HttpHeaders>(url: String | UrlBuilder, headers: HttpHeaders = {}, body: HttpBody | Null = null, requestConfig: HttpRequestConfig = DEFAULT_HTTP_REQUEST_CONFIG, serializationConfig: SerializationConfig = DEFAULT_SERIALIZATION_CONFIG, clientConfig: HttpClientConfig = DEFAULT_HTTP_CLIENT_CONFIG): HttpResponse<B, H>

Helper function to send a DELETE HTTP request.

Parameters
Name Type Description
url String &#124; UrlBuilder The desired HTTP request url.
headers HttpHeaders The HTTP request header to send.
body HttpBody &#124; Null The HTTP request body to send.
requestConfig HttpRequestConfig The HTTP request configuration to use.
serializationConfig SerializationConfig The HTTP serialization configuration to use.
clientConfig HttpClientConfig The HTTP client configuration configuration to use.

get

get<B <: HttpBody, H <: HttpHeaders>(url: String | UrlBuilder, headers: HttpHeaders = {}, requestConfig: HttpRequestConfig = DEFAULT_HTTP_REQUEST_CONFIG, serializationConfig: SerializationConfig = DEFAULT_SERIALIZATION_CONFIG, clientConfig: HttpClientConfig = DEFAULT_HTTP_CLIENT_CONFIG): HttpResponse<B, H>

Helper function to send a GET HTTP request.

Parameters
Name Type Description
url String &#124; UrlBuilder The desired HTTP request url.
headers HttpHeaders The HTTP request header to send.
requestConfig HttpRequestConfig The HTTP request configuration to use.
serializationConfig SerializationConfig The HTTP serialization configuration to use.
clientConfig HttpClientConfig The HTTP client configuration configuration to use.

head

head<B <: HttpBody, H <: HttpHeaders>(url: String | UrlBuilder, headers: HttpHeaders = {}, requestConfig: HttpRequestConfig = DEFAULT_HTTP_REQUEST_CONFIG, serializationConfig: SerializationConfig = DEFAULT_SERIALIZATION_CONFIG, clientConfig: HttpClientConfig = DEFAULT_HTTP_CLIENT_CONFIG): HttpResponse<B, H>

Helper function to send a HEAD HTTP request.

Parameters
Name Type Description
url String &#124; UrlBuilder The desired HTTP request url.
headers HttpHeaders The HTTP request header to send.
requestConfig HttpRequestConfig The HTTP request configuration to use.
serializationConfig SerializationConfig The HTTP serialization configuration to use.
clientConfig HttpClientConfig The HTTP client configuration configuration to use.

options

options<B <: HttpBody, H <: HttpHeaders>(url: String | UrlBuilder, headers: HttpHeaders = {}, requestConfig: HttpRequestConfig = DEFAULT_HTTP_REQUEST_CONFIG, serializationConfig: SerializationConfig = DEFAULT_SERIALIZATION_CONFIG, clientConfig: HttpClientConfig = DEFAULT_HTTP_CLIENT_CONFIG): HttpResponse<B, H>

Helper function to send a OPTIONS HTTP request.

Parameters
Name Type Description
url String &#124; UrlBuilder The desired HTTP request url.
headers HttpHeaders The HTTP request header to send.
requestConfig HttpRequestConfig The HTTP request configuration to use.
serializationConfig SerializationConfig The HTTP serialization configuration to use.
clientConfig HttpClientConfig The HTTP client configuration configuration to use.

patch

patch<B <: HttpBody, H <: HttpHeaders>(url: String | UrlBuilder, headers: HttpHeaders = {}, body: HttpBody | Null = null, requestConfig: HttpRequestConfig = DEFAULT_HTTP_REQUEST_CONFIG, serializationConfig: SerializationConfig = DEFAULT_SERIALIZATION_CONFIG, clientConfig: HttpClientConfig = DEFAULT_HTTP_CLIENT_CONFIG): HttpResponse<B, H>

Helper function to send a PATCH HTTP request.

Parameters
Name Type Description
url String &#124; UrlBuilder The desired HTTP request url.
headers HttpHeaders The HTTP request header to send.
body HttpBody &#124; Null The HTTP request body to send.
requestConfig HttpRequestConfig The HTTP request configuration to use.
serializationConfig SerializationConfig The HTTP serialization configuration to use.
clientConfig HttpClientConfig The HTTP client configuration configuration to use.

post

post<B <: HttpBody, H <: HttpHeaders>(url: String | UrlBuilder, headers: HttpHeaders = {}, body: HttpBody | Null = null, requestConfig: HttpRequestConfig = DEFAULT_HTTP_REQUEST_CONFIG, serializationConfig: SerializationConfig = DEFAULT_SERIALIZATION_CONFIG, clientConfig: HttpClientConfig = DEFAULT_HTTP_CLIENT_CONFIG): HttpResponse<B, H>

Helper function to send a POST HTTP request.

Parameters
Name Type Description
url String &#124; UrlBuilder The desired HTTP request url.
headers HttpHeaders The HTTP request header to send.
body HttpBody &#124; Null The HTTP request body to send.
requestConfig HttpRequestConfig The HTTP request configuration to use.
serializationConfig SerializationConfig The HTTP serialization configuration to use.
clientConfig HttpClientConfig The HTTP client configuration configuration to use.

postMultipart

postMultipart<B <: HttpBody, H <: HttpHeaders>(url: String | UrlBuilder, body: Multipart, headers: HttpHeaders = {}, requestConfig: HttpRequestConfig = DEFAULT_HTTP_REQUEST_CONFIG, serializationConfig: SerializationConfig = DEFAULT_SERIALIZATION_CONFIG, clientConfig: HttpClientConfig = DEFAULT_HTTP_CLIENT_CONFIG): HttpResponse<B, H>

Helper function to send a multipart HTTP request.

Parameters
Name Type Description
url String &#124; UrlBuilder The desired HTTP request url.
body Multipart The HTTP request body to send.
headers HttpHeaders The HTTP request header to send.
requestConfig HttpRequestConfig The HTTP request configuration to use.
serializationConfig SerializationConfig The HTTP serialization configuration to use.
clientConfig HttpClientConfig The HTTP client configuration configuration to use.

put

put<B <: HttpBody, H <: HttpHeaders>(url: String | UrlBuilder, headers: HttpHeaders = {}, body: HttpBody | Null = null, requestConfig: HttpRequestConfig = DEFAULT_HTTP_REQUEST_CONFIG, serializationConfig: SerializationConfig = DEFAULT_SERIALIZATION_CONFIG, clientConfig: HttpClientConfig = DEFAULT_HTTP_CLIENT_CONFIG): HttpResponse<B, H>

Helper function to send a PUT HTTP request.

Parameters
Name Type Description
url String &#124; UrlBuilder The desired HTTP request url.
headers HttpHeaders The HTTP request header to send.
body HttpBody &#124; Null The HTTP request body to send.
requestConfig HttpRequestConfig The HTTP request configuration to use.
serializationConfig SerializationConfig The HTTP serialization configuration to use.
clientConfig HttpClientConfig The HTTP client configuration configuration to use.

readBody

readBody<B <: HttpBody>(mimeType: String, body: Binary, readerProperties: Object = {}): B

Helper function to read a Binary body instance.

Parameters
Name Type Description
mimeType String The MIME type to use.
body Binary The desired body parse.
readerProperties Object The reader configuration properties used for read the body.

readHttpResponseBody

readHttpResponseBody<B <: HttpBody, H <: HttpHeaders>(httpResponse: HttpResponse<Binary, H>, serializationConfig: SerializationConfig): HttpResponse<B, H>

Helper function to read a HttpResponse with a Binary body instance.

Parameters
Name Type Description
httpResponse HttpResponse<Binary,H&#62; The desired HttpResponse to parse.
serializationConfig SerializationConfig The HTTP serialization configuration to use.

resolveTemplateWith

resolveTemplateWith(uri: String, context: Object): String

Replace the templates of a url according to RFC6570


sendRequest

sendRequest<B <: HttpBody, H <: HttpHeaders>(request: HttpRequest, binaryRequestEncoder: BinaryRequestEncoder, binaryResponseDecoder: BinaryResponseDecoder<B, H>, requestConfig: HttpRequestConfig = DEFAULT_HTTP_REQUEST_CONFIG, clientConfig: HttpClientConfig = DEFAULT_HTTP_CLIENT_CONFIG): HttpResponse<B, H>

Sends an HTTP request by using the provided binaryRequestEncoder to convert the current request into an HttpRequest<Binary,H&#62; instance with the desired configurations (request/client configuration) and returns an HTTP response using the provided binaryResponseDecoder to convert the current HTTP response into an HttpResponse<B, H&#62;> instance.

Parameters
Name Type Description
request HttpRequest An HTTP request to send.
binaryRequestEncoder BinaryRequestEncoder The HTTP request encoder to use.
binaryResponseDecoder BinaryResponseDecoder The HTTP response decoder to use.
requestConfig HttpRequestConfig The HTTP request configuration to use.
clientConfig HttpClientConfig The HTTP client configuration configuration to use.

sendRequest<B <: HttpBody, H <: HttpHeaders>(request: HttpRequest<Binary>, binaryResponseDecoder: BinaryResponseDecoder<B, H>, requestConfig: HttpRequestConfig = DEFAULT_HTTP_REQUEST_CONFIG, clientConfig: HttpClientConfig = DEFAULT_HTTP_CLIENT_CONFIG): HttpResponse<B, H>

Sends an HttpRequest<Binary,H> instance with the desired configurations (request/client configuration) and returns an HTTP response using the provided binaryResponseDecoder to convert the current HTTP response into an HttpResponse<B, H&#62;> instance.

Parameters
Name Type Description
request HttpRequest<Binary,H&#62; An HTTP request to send.
binaryResponseDecoder BinaryResponseDecoder The HTTP response decoder to use.
requestConfig HttpRequestConfig The HTTP request configuration to use.
clientConfig HttpClientConfig The HTTP client configuration configuration to use.

sendRequest<H <: HttpHeaders>(request: HttpRequest, binaryRequestEncoder: BinaryRequestEncoder, requestConfig: HttpRequestConfig = DEFAULT_HTTP_REQUEST_CONFIG, clientConfig: HttpClientConfig = DEFAULT_HTTP_CLIENT_CONFIG): HttpResponse<Binary, H>

Sends an HTTP request by using the provided binaryRequestEncoder to convert the current request into an HttpRequest<Binary,H&#62; instance with the desired configurations (request/client configuration) and returns an HttpResponse<Binary, H&#62;> instance.

Parameters
Name Type Description
request HttpRequest An HTTP request to send.
binaryRequestEncoder BinaryRequestEncoder The HTTP request encoder to use.
requestConfig HttpRequestConfig The HTTP request configuration to use.
clientConfig HttpClientConfig The HTTP client configuration configuration to use.

sendRequest<H <: HttpHeaders>(request: HttpRequest<Binary>, requestConfig: HttpRequestConfig = DEFAULT_HTTP_REQUEST_CONFIG, clientConfig: HttpClientConfig = DEFAULT_HTTP_CLIENT_CONFIG): HttpResponse<Binary, H>

Sends an HTTP request with a Binary body instance with the desired configurations (request/client configuration) and returns an HttpResponse<Binary, H&#62;> instance.

Parameters
Name Type Description
request HttpRequest<Binary,H&#62; An HTTP request to send.
requestConfig HttpRequestConfig The HTTP request configuration to use.
clientConfig HttpClientConfig The HTTP client configuration configuration to use.

sendRequestAndReadResponse

sendRequestAndReadResponse<B <: HttpBody, H <: HttpHeaders>(request: HttpRequest, requestConfig: HttpRequestConfig = DEFAULT_HTTP_REQUEST_CONFIG, serializationConfig: SerializationConfig = DEFAULT_SERIALIZATION_CONFIG, clientConfig: HttpClientConfig = DEFAULT_HTTP_CLIENT_CONFIG): HttpResponse<B, H>

Sends an HTTP request by writing the request body into a Binary instance and reading the HTTP response Binary body instance.

Parameters
Name Type Description
request HttpRequest An HTTP request to send.
requestConfig HttpRequestConfig The HTTP request configuration to use.
serializationConfig SerializationConfig The HTTP serialization configuration to use.
clientConfig HttpClientConfig The HTTP client configuration configuration to use.

trace

trace<B <: HttpBody, H <: HttpHeaders>(url: String | UrlBuilder, headers: HttpHeaders = {}, requestConfig: HttpRequestConfig = DEFAULT_HTTP_REQUEST_CONFIG, serializationConfig: SerializationConfig = DEFAULT_SERIALIZATION_CONFIG, clientConfig: HttpClientConfig = DEFAULT_HTTP_CLIENT_CONFIG): HttpResponse<B, H>

Helper function to send a TRACE HTTP request.

Parameters
Name Type Description
url String &#124; UrlBuilder The desired HTTP request url.
headers HttpHeaders The HTTP request header to send.
requestConfig HttpRequestConfig The HTTP request configuration to use.
serializationConfig SerializationConfig The HTTP serialization configuration to use.
clientConfig HttpClientConfig The HTTP client configuration configuration to use.

url

url(parts: Array<String>, interpolation: Array<StringCoerceable>): String

String interpolator function to build a URL


Variables

DEFAULT_HTTP_CLIENT_CONFIG

Variable used to identify the default HTTP client configuration.

DEFAULT_HTTP_REQUEST_CONFIG

Variable used to identify the default HTTP request configuration.

DEFAULT_SERIALIZATION_CONFIG

Variable used to identify the default HTTP serialization configuration.