Modeling Guide

HTTP Client

An HTTP client operator capable of sending arbitrary HTTP requests, polling a URL and, posting JSON data.

Configuration Parameters

Parameter

Type

Description

postUrl

string

The URL to which data from the in port is posted. This property can only be empty if the in port is not connected.

Default: "http://localhost:7070"

getUrl

string

The URL to be polled for data with GET requests.

Default: "http://localhost:7070"

getPeriodInMs

int

The period in milliseconds to be used for polling getUrl.

Default: 1000

numRetryAttempts

int

The number of times to retry a failed request.

Default: 0

requestTimeoutInMs

int

The number of milliseconds to wait for a response before timing out.

Default: 5000

retryPeriodInMs

int

The number of milliseconds to wait between consecutive retry attempts.

Default: 0

Proxy

string

A URL to be used as proxy server. If empty, the client will fallback to the system's configuration (HTTP_PROXY and HTTPS_PROXY environment variables and their lower-case counterparts).

Input

Input

Type

Description

in

blob

The input JSON data that will be posted to postUrl.

inRequest

message

A message specifying a custom HTTP request to be sent. The message must contain attributes http.url (destination address) and http.method (the HTTP method for the request). The request will obey the values given to numRetryAttempts, requestTimeoutInMs and retryPeriodInMs.

HTTP Header Fields:
  • You can set any RFC 7230-compliant HTTP header field by prepending its name with http. as a message attribute. For example, when creating a message in a JavaScript Operator:
    message.Attributes["http.Content-Type"] = "text/json";
    Then, the HTTP Client will automatically convert this to:
    Content-Type: text/json
    in the request's header.
  • Fields Content-Length, Transfer-Encoding and Connection will be added automatically, as needed.
  • Field names are case-insensitive (RFC 7230 -- section 3.2).

Output

Output

Type

Description

out

blob

The output data in JSON format.

outResponse

message

The complete response given by the remote peer. The message will contain the following attributes:
  • http.status (type string): the returned status (e.g. "200 OK").
  • http.statusCode (type int): the code of the returned status (e.g. 200).
  • http.url (type string): the URL of the remote peer.
  • http.method (type string): the HTTP method (e.g. "GET").
  • All HTTP header fields sent by the server, prepended by http. e.g. field Content-Type becomes message attribute http.Content-Type)

Error Handling

Since, in some cases, there can be expected errors that should not cause the graph to stop, please observe the following behavior:
  • If port outResponse is connected:
    • If an error occurred and no response was received, an error is thrown.
    • If a response was received, it will be written to this port regardless of the contained HTTP status.
    • The user is free to decide on the appropriate treatment for each HTTP status by reading it from the http.status and http.statusCode message attributes.
  • If port outResponse is not connected, then this operator will throw an error itself if the request failed or if the status in the remote peer's response is anything other than HTTP OK (200).
  • Port out does not affect the above error handling policy, and the body of a response will only be written to this port if the status was HTTP OK (200).

TLS Certificates

Due to limited filesystem manipulation capabilities, the HTTP Client will automatically load and use any certificate files in its directory that have the .crt extension. To upload a certificate, use the Repository tab, browse to the HTTP Client's editor page and use the Upload Auxiliary File button.