HTTPSend

Description: Sends HTTP requests to an HTTP server
Returns:

A reference to itself so that you can monitor for completion.

See also pResponse in the comments.

Usage: Script Only.
Function Groups: Stream and Buffer
Related to:  
Format: System.HTTPClient.HTTPSend(URL, pResponse[, Username, Password, ExtraHeaders, Action, MessageBody, ContentType, TimeLimit, NConcurrent, KeepAlive, MessageOnly, MaxSendRate ])
Parameters:  
URL
Full URL
pResponse
[OUT] Pointer set to a response structure when request completes
Username
Optional text. Self explanatory.
Password

Optional text. Self explanatory.

The HTTP client supports both HTTP basic and digest authentication schemes

ExtraHeaders
Dictionary of extra HTTP headers where the dictionary key is used as the header name and its value as the header value
Action
Typically "POST" or "GET"; default GET
MessageBody
The "payload" of the HTTP message
ContentType
Meaningful only if MessageBody is valid; default "text/xml; charset="UTF-8""
TimeLimit
Time in seconds to wait for response; default 60
NConcurrent
Number of concurrent keep-alive connections to maintain per server-port; default 1
KeepAlive
TRUE to keep the connection alive; default TRUE
MessageOnly
TRUE to just send the message body; default FALSE
MaxSendRate
Optional numeric. the maximum number of requests to send per second to the host. Defaults to an unlimited rate if not specified. (See comments)
Comments:

Note that HTTPSend is part of the HTTPClient library, which is part of the System library, and therefore must be used in the form, System.HTTPClient.HTTPSend(...

The response structure contains the following fields:

ReturnCode

The response code. See following notes.

Body

The response body

Headers

A dictionary of response headers

ErrorText

Supplementary error text beyond ReturnCode

The ReturnCode will either be a standard HTTP status code, such as 200 for success, or one of the following:

  • -1: Connection timed out
  • -2: Response timed out
  • -3: Invalid (non-HTTP) response
  • -4: Incomplete response
  • -5: Unsupported transfer-encoding
  • -6: Missing parameters

Related properties in Setup.INI:

HTTPClientKeepAliveTime

The length of time to maintain an inactive HTTP connection marked as "keepalive". Default is 15 seconds.

HTTPMaxDeflatedDataSize

An integer that specifies the max size of a payload to decompress. If the payload is bigger than this size it will be truncated. Defaults to 65536 bytes.

There is risk when changing this setting: If it is too large, and a bad payload is received, it could cause VTScada to allocate a buffer of the max size. Most users should not need to change this property.

MaxSendRate

The maximum number of requests to send per second to the host. It defaults to an unlimited rate. This is necessary for situations where a host may reject a client if it has received more than X requests per second from that client. By setting MaxSendRate, HTTPClient throttles the rate at which it sends messages.