Errors
The functions raise these errors. Catch them with a variable of type ERROR on the CALL line, and check its code.
INVALID_ARGUMENT
Code 309: the connection is not valid.
The server is empty, the port is not 0 to 65535, the timeout is not 0 to 300, the proxy is not an http:// URL, or a header can't be sent. It is also raised if the request is larger than 1,000,000 bytes.
HTTP_STATUS
Code 1000: the server answered with a status of 400 or higher.
The message is the status line, like 404 Not Found. The results result, status and headers are delivered as well, so a program that catches the error can read the answer.
Example
CALL c0de_net/http/HTTP_GET problem
PARAMETER connection api ;
PARAMETER endpoint "/lamps/attic" ;
RESULT status status
IF problem.code = 1000 AND status = 404 ;
BEGIN
CALL PRINT
PARAMETER value "There is no lamp in the attic" ;
END IFCLIENT_UNAVAILABLE
Code 1001: there is no client to send the request.
The player who runs the process is not online, or their game doesn't have c0de net installed. A process that nobody started and whose trigger block has no owner can't send requests either.
REQUESTS_DISABLED
Code 1002: the client of the player who runs the process doesn't send requests.
That player has set allowRequests=false in config/c0de_net-client.properties.
REQUEST_FAILED
Code 1003: the request could not be sent, or there was no answer.
The message names the reason, like an unknown host, a refused connection, a failed SSL handshake or a proxy error. A self-signed certificate needs skip_ssl_validation.
REQUEST_TIMEOUT
Code 1004: there was no complete answer within the timeout of the connection.
The timeout covers the whole request, until the last byte of the answer. Raise timeout for slow servers, up to 300 seconds.
RESPONSE_TOO_LARGE
Code 1005: the answer is larger than the server allows.
The limit is maxResponseSize in config/c0de_net.properties, 1 MiB by default. Ask the API for less data, e.g. one page of a list.