http/request
src/http/request.tur
defn
request
(request [method : cstr url : cstr body : cstr headers : int] :)
create an HTTP request handle.
Parameters
| method | HTTP method string ("GET", "POST", ...) | |
| url | full URL including scheme, e.g. "https://example.com/api" | |
| body | request body string ("" for no body) | |
| headers | cons-list of alternating header-name / header-value strings. | |
| Pass (nil-value) for no extra headers. |
Returns
:int -- opaque request handle; pass to http-request
Example
(let [req (request "GET" "https://example.com" "" (nil-value))]
(http-request req))
Since: P5
defn
json-request
(json-request [^EncodeJson T method : cstr url : cstr x : T headers : int] :)
defn
request-free
(request-free [req : int] :)
release a request record built by request / json-request.
Parameters
| req | request handle |
Returns
:void
Example
(let [req (request "GET" "http://127.0.0.1:8080/" "" 0)
r (http-request req)]
(request-free req)
(http-result-free r))
Since: 0.2.0
Internal definitions
__cstr-free-- release a malloc'd JSON fragment returned by `encode-json`.__hdr-cons-- prepend a `key`/`val` header pair onto a header cons-list.__req-own-cells!-- build an HTTP request whose body is `x` encoded as JSON,