HTTP requests

This controller allow scripts to issue http/https requests.

For https, CA certificate has to be in configuration in certs/exernal.

http.doDelete(url: string, request?: HttpScriptRequest)

Send HTTP/S request using DELETE method.

Arguments:
  • url

  • request

Returns:

Response of the request of type HttpScriptResponse()

http.doGet(url: string, request?: HttpScriptRequest)

Send HTTP/S request using GET method.

Arguments:
  • url

  • request

http.doPost(url: string, request?: HttpScriptRequest)

Send HTTP/S request using POST method.

Arguments:
  • url

  • request

http.doPut(url: string, request?: HttpScriptRequest)

Send HTTP/S request using PUT method.

Arguments:
  • url

  • request

http.getRequest()

This method is a helper to get an http object pre-defined with only data to fill.

Returns:

Return a HttpScriptRequest() to help to build a request.

class http.HttpScriptRequest()

One two one two, this is a test

HttpScriptRequest.addHeader(key: string, value: string)

Add a custom header for this request.

Arguments:
  • key

  • value

Returns:

Return a the request (HttpScriptRequest())filled with new attribute.

HttpScriptRequest.notFollowRedirects(notFollow: boolean)

Set whether the request follows redirect or not

Arguments:
  • notFollow – True mean that request won’t follow redirects.

Returns:

Return a the request (HttpScriptRequest())filled with new attribute.

HttpScriptRequest.setBody(body: <string | object>, contentType?: string)

Set the body of the request.

Arguments:
  • body

  • contentType

Returns:

Return a the request (HttpScriptRequest())filled with new attribute.

HttpScriptRequest.setCredential(username: string, password: string)

Add username/password authentication to request.

Arguments:
  • username

  • password

Returns:

Return a the request (HttpScriptRequest())filled with new attribute.

HttpScriptRequest.setTimeout(timeoutMs: number)
Arguments:
  • timeoutMs – Time in [ms] before request fail in case of no response.

class http.HttpScriptResponse()

Represent a response of an HTTP/S request.

HttpScriptResponse.getBody()

Get body of the request response.

HttpScriptResponse.getError()

Get error message of the request response.

HttpScriptResponse.getHeader()

Get header of the HTTP/S response.

HttpScriptResponse.getStatusCode()

Get HTTP/S status code responded by the server.

HttpScriptResponse.isSuccess()

Read overall status of the request.