Operational Settings
Operational settings affect how HttpCommand
behaves.
Instance settings
KeepAlive
Description | A Boolean which indicates whether HttpCommand close the client connection after receiving the response from the host.
|
Default | 1 |
Example(s) | h.KeepAlive←0 ⍝ close the connection |
Details | KeepAlive is only applicable when you persist an instance of HttpCommand and has no effect when you use the shortcut methods Get , GetJSON , or Do as these methods destroy the HttpCommand instance they create when they finish execution. HTTP version 1.1 specifies that connections should be kept alive to improve throughput. Nevertheless, a host may close the connection after sending the response or after a period of inactivity from the client (HttpCommand ). If the connection is closed, HttpCommand will open a new connection on a subsequent request. |
MaxPayloadSize
Description | The maximum response payload size that HttpCommand will accept.
|
Default | ¯1 |
Example(s) | h.MaxPayloadSize←100000 ⍝ set a 100,000 byte limit |
Details | If MaxPayloadSize is set to a value ≥0 and the response contains a payload, HttpCommand checks the payload size as follows:
MaxPayloadSize is exceeded, the client connection will be closed. |
MaxRedirections
Description | The maximum number of redirections that HttpCommand will follow.A setting of ¯1 means there is no limit to the number of redirections followed; exposing the possibility of an infinite redirection loop and eventually a WS FULL error. A setting of 0 means no redirections will be followed. |
Default | 10 |
Example(s) | h.MaxRedirections←0 ⍝ do not follow any redirections
|
Details | If the response HTTP status indicates a redirection (3XX) to another URL, HttpCommand will retain information about the current request in the Redirections element of the result namespace and issue a new request to the new URL. HttpCommand will do this up to MaxRedirections times. |
Outfile
Description | Outfile has up to 2 elements:
|
Default | '' 0 |
Example(s) | c ← HttpCommand.New '' c.URL←'https://www.dyalog.com/uploads/files/student_competition/2022_problems_phase2.pdf' c.OutFile←'/tmp/' c.Run [rc: 0 | msg: | HTTP Status: 200 "OK" | 399766 bytes written to c:/tmp/2022_problems_phase2.pdf] |
Details | Output to file is subject to MaxPayloadSize . |
RequestOnly
Description | If set to 1, HttpCommand will return the character vector HTTP request that would be sent, instead of actually sending the request. |
Default | 0 |
Example(s) | h.RequestOnly←1 |
Details | This setting is useful for debugging a request that isn't behaving as you expect. Setting optional left argument of shared methods Get , GetJSON , Do , or New to 1 will have the same effect as setting RequestOnly as will the instance method Show . |
SuppressHeaders
Description | SuppressHeaders is a Boolean setting indicating whether HttpCommand should suppress the generation of its default HTTP headers for the request.
|
Default | 0 which means HttpCommand will generate its default headers |
Example(s) | h.SuppressHeaders←1 |
Details | HttpCommand will only generate headers that you have not specified yourself. HttpCommand generates the following default headers:
|
Timeout
Description | The number of seconds that HttpCommand will count down to wait for a response. If Timeout is positive, HttpCommand will wait to receive the complete response from the host. If Timeout is negative, the countdown will be reset to |Timeout if Conga has received any data. |
Default | 10 |
Example(s) | h.Timeout←30 |
Details | Timeout should be set to a time value larger than WaitTime . Note that Timeout is in seconds and WaitTime is in milliseconds. |
TranslateData
Description | Set this to 1 to have HttpCommand attempt to convert the response payload for the following content types.
|
Default | 0 |
Example(s) |
c←HttpCommand.New 'get' 'https://api.github.com/users/dyalog'
|
Shared Settings
Shared settings are set in the HttpCommand
class and are used by all instances of HttpCommand
.
Debug
Description | Set Debug to 1 to turn off HttpCommand 's error trapping. In this case if an error occurs, execution of HttpCommand will be suspended. Set Debug to 2 to have HttpCommand stop just before sending the request to the host so that you can examine the request and HttpCommand 's current state. Both of these settings can be useful for debugging. |
Default | 0 |
Example(s) |
c←HttpCommand.New 'get' 'https://api.github.com/users/dyalog' c.OutFile←0 c.Debug←1 c.Run DOMAIN ERROR: Invalid file or directory name HttpCmd[130] outFile←∊1 ⎕NPARTS outFile ∧ c.Debug←0 c.Run [rc: ¯1 | msg: DOMAIN ERROR while trying to initialize output file '0' | HTTP Status: "" | ⍴Data: 0]
|