senses:packages:kmj-http
Differences
This shows you the differences between two versions of the page.
senses:packages:kmj-http [2025/07/28 02:55] – created flash | senses:packages:kmj-http [2025/07/28 03:28] (current) – args & rets on same level as syntax + other adjustments flash | ||
---|---|---|---|
Line 33: | Line 33: | ||
send(method: | send(method: | ||
- | === Arguments === | + | ==== Arguments |
- The first argument should be any valid HTTP method verb. If you're using one of the aliases above, this argument will be implicitly set. | - The first argument should be any valid HTTP method verb. If you're using one of the aliases above, this argument will be implicitly set. | ||
Line 40: | Line 40: | ||
- The fourth argument may contain the body of the request. This data may be remapped according to changes made to the options argument. | - The fourth argument may contain the body of the request. This data may be remapped according to changes made to the options argument. | ||
- | === Return values | + | ==== Returns ==== |
- The first return value will contain the body of the response data. Status code and response headers can be retrieved through a callback specified in the options table. | - The first return value will contain the body of the response data. Status code and response headers can be retrieved through a callback specified in the options table. | ||
- | ==== Options ==== | + | ===== Options |
Below are possible the fields that may be part of the options table provided to the third argument or the send function. | Below are possible the fields that may be part of the options table provided to the third argument or the send function. | ||
- | === timeout === | + | ==== timeout |
The timeout field may contain a number the indicates the amount of milliseconds that the request may take to complete before it is aborted. Specifying a value less than '' | The timeout field may contain a number the indicates the amount of milliseconds that the request may take to complete before it is aborted. Specifying a value less than '' | ||
- | === type === | + | ==== type ==== |
The type field may contain a string that determines the expected format of response body, if the actual format is incompatible the return value will be '' | The type field may contain a string that determines the expected format of response body, if the actual format is incompatible the return value will be '' | ||
Line 64: | Line 64: | ||
| '' | | '' | ||
- | == Formatting of the XML Lua tables == | + | === Formatting of the XML Lua tables |
Because I have absolutely zero intention of providing any sort of proper XML handling for the sanity of everyone involved in the project, the details on how XML documents are decoded is described in the following blob of text: | Because I have absolutely zero intention of providing any sort of proper XML handling for the sanity of everyone involved in the project, the details on how XML documents are decoded is described in the following blob of text: | ||
Line 76: | Line 76: | ||
- Use literally any other encoding, please be nicer to yourself. | - Use literally any other encoding, please be nicer to yourself. | ||
- | === requestHeaders === | + | ==== requestHeaders |
The requestHeaders field may contain a key/value table describes headers to be sent in your request. Both the field names and field values should be strings, header names are case insensitive. | The requestHeaders field may contain a key/value table describes headers to be sent in your request. Both the field names and field values should be strings, header names are case insensitive. | ||
- | == Content-Type header behaviour == | + | === Content-Type header behaviour |
The value of the Content-Type header affects how the fourth argument, requestBody, | The value of the Content-Type header affects how the fourth argument, requestBody, | ||
Line 96: | Line 96: | ||
| '' | | '' | ||
- | === responseHeaders === | + | ==== responseHeaders |
The responseHeaders field may contain a function that receives the HTTP status code and response headers before the body has been processed. | The responseHeaders field may contain a function that receives the HTTP status code and response headers before the body has been processed. | ||
- | == Syntax == | + | === Syntax |
callback(statusCode: | callback(statusCode: | ||
- | == Arguments == | + | === Arguments |
- The first argument will contain the HTTP status code. | - The first argument will contain the HTTP status code. | ||
- The second argument will contain a table containing the response headers in a similar format as the requestHeaders options field. Header names are normalised to lowercase to allow for easy indexing. | - The second argument will contain a table containing the response headers in a similar format as the requestHeaders options field. Header names are normalised to lowercase to allow for easy indexing. | ||
- | == Return values == | + | === Return values |
//This callback does not expect any return values. In the future this callback may gain the ability to interrupt the processing of the body, so please DO NOT return anything.// | //This callback does not expect any return values. In the future this callback may gain the ability to interrupt the processing of the body, so please DO NOT return anything.// |
senses/packages/kmj-http.txt · Last modified: by flash