BQN HTTP library, from libcurl FFI bindings
config.bqn | ||
curl.bqn | ||
ffi.bqn | ||
LICENSE | ||
README.org | ||
test.bqn | ||
utils.bqn |
BQN HTTP library
FFI bindings to libcurl for BQN.
Making requests
Only GET and POST requests are implemented at this time.
⟨Get,Post⟩←•Import"curl.bqn"
Simple GET requests:
r←Get"https://httpbin.org/get"
You can pass headers as a left argument:
r←⟨"Content-Type: application/json"⟩Get"https://httpbin.org/get"
Arguments, port number, etc, can be included in the URL.
For POST requests, pass data as an additional string parameter. It will not be converted or encoded in any way.
r←⟨"Content-Type: application/json"⟩Post"https://httpbin.org/post"‿"{""key"": ""value""}"
Response objects
The response object is a namespace with the following elements:
code
: the response code.headers
: the response headers as a single string, separated by newlines.content
: the response content, as raw bytes.time
: the time the request took, in seconds.
If your endpoint returns text, you can use FromBytes
from
bqn-libs/strings.bqn to decode UTF-8.