mirror of
https://github.com/KumoCorp/kumomta.git
synced 2026-08-20 00:01:15 +00:00
42bf5c5e61
We've been hoping that mkdocs-material will ship the much anticipated search enhancements for some time, but it's time to recognize that we need to do something to improve the search results with how things work right now. This is a big commit that changes the titles of the various pages from the code-annotated synopsis to just the name of the function. This makes it much easier now to match things like `kumo.reject` directly, but `reject` remains awkward to find. I think this is the best that we can do at this time. A few functions have been annotated with the `status: deprecated` to show as deprecated in the toc/nav (shows with a little trash can next to the name).
1.9 KiB
1.9 KiB
kumo.http.build_client
kumo.http.build_client { PARAMS }
Constructs an HTTP client object.
The client maintains state, including a connection pool, that can be used across multiple HTTP requests.
PARAMS is an object-style table with the following keys:
user_agent- optional string that will be used to set theUser-Agentheader for all requests made by the clientconnection_verbose- optional boolean. If true, additional diagnostics around the connection attempt will be logged and can be seen by setting the diagnostic filter to includereqwest=trace. {{since('2024.06.10-84e84b89', inline=True)}}pool_idle_timeout- optional duration. Sets the maximum time that an idle connection remains in the connection pool. The default is90 seconds. {{since('2024.06.10-84e84b89', inline=True)}}.timeout- optional duration. Sets the default timeout to use for each request made by the client. Can be overridden using the Request object. The default is60 seconds. {{since('2024.06.10-84e84b89', inline=True)}}.
local response = kumo.http.build_client({}):get('https://example.com/'):send()
print(response:status_code(), response:status_reason())
for k, v in pairs(response:headers()) do
print('Header', k, v)
end
print(response:text())
Client Methods
The returned client object has the following methods:
client:get(URL)
Returns a Request object that has been configured to make a GET request to the specified URL. The URL is a string.
client:post(URL)
Returns a Request object that has been configured to make a POST request to the specified URL. The URL is a string.
client:put(URL)
Returns a Request object that has been configured to make a PUT request to the specified URL. The URL is a string.
client:close()
{{since('2024.09.02-c5476b89')}}
Explicitly destroy the client, closing any connections in its cache.