BQN HTTP library, from libcurl FFI bindings
Find a file
2023-10-02 13:33:52 +02:00
config.bqn Initial commit: GET requests 2023-10-01 17:01:26 +02:00
curl.bqn Refactor request building 2023-10-02 13:33:52 +02:00
ffi.bqn Refactor request building 2023-10-02 13:33:52 +02:00
LICENSE Add license and readme 2023-10-01 19:17:17 +02:00
README.org Add help for configuration in the readme 2023-10-01 21:27:22 +02:00
tests.bqn Rename test.bqn → tests.bqn 2023-10-01 19:31:41 +02:00
utils.bqn Initial commit: GET requests 2023-10-01 17:01:26 +02:00

BQN HTTP library

FFI bindings to libcurl for BQN.

Configuration

Set the location of the libcurl.so library in config.bqn.

Making requests

Only GET and POST requests are implemented at this time.

Get,Post•Import"curl.bqn"

Simple GET requests:

rGet"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.

Tests

Run a local httpbin.org instance with Docker:

docker run -p 8080:80 kennethreitz/httpbin

The tests can be run with bqn tests.bqn.