{"id":13716475,"url":"https://github.com/dlozeve/bqn-curl","last_synced_at":"2025-04-12T02:03:45.492Z","repository":{"id":197612152,"uuid":"698976711","full_name":"dlozeve/bqn-curl","owner":"dlozeve","description":"BQN HTTP library, from libcurl FFI bindings","archived":false,"fork":false,"pushed_at":"2023-10-02T19:24:05.000Z","size":23,"stargazers_count":9,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-12T02:03:35.503Z","etag":null,"topics":["bqn","ffi","http","http-client","http-requests","libcurl","libcurl-bindings"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dlozeve.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-10-01T15:02:39.000Z","updated_at":"2025-03-06T06:45:32.000Z","dependencies_parsed_at":"2024-01-06T00:04:55.482Z","dependency_job_id":null,"html_url":"https://github.com/dlozeve/bqn-curl","commit_stats":null,"previous_names":["dlozeve/bqn-curl"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlozeve%2Fbqn-curl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlozeve%2Fbqn-curl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlozeve%2Fbqn-curl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlozeve%2Fbqn-curl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dlozeve","download_url":"https://codeload.github.com/dlozeve/bqn-curl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505863,"owners_count":21115354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bqn","ffi","http","http-client","http-requests","libcurl","libcurl-bindings"],"created_at":"2024-08-03T00:01:10.878Z","updated_at":"2025-04-12T02:03:45.470Z","avatar_url":"https://github.com/dlozeve.png","language":null,"funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"* BQN HTTP library\n\nFFI bindings to [[https://curl.se/libcurl/][libcurl]] for [[https://mlochbaum.github.io/BQN/][BQN]].\n\n** Configuration\n\nSet the location of the =libcurl.so= library in [[./config.bqn][config.bqn]].\n\n** Usage\n\n*** Simple API\n\nOnly GET and POST requests are implemented at this time.\n\n#+begin_src bqn\n⟨Get,Post⟩←•Import\"curl.bqn\"\n#+end_src\n\nSimple GET requests:\n#+begin_src bqn\nr←Get\"https://httpbin.org/get\"\n#+end_src\n\nYou can pass headers as a left argument:\n#+begin_src bqn\nr←⟨\"Content-Type: application/json\"⟩Get\"https://httpbin.org/get\"\n#+end_src\n\nArguments, port number, etc, can be included in the URL.\n\nFor POST requests, pass data as an additional string parameter. It\nwill not be converted or encoded in any way.\n#+begin_src bqn\nr←⟨\"Content-Type: application/json\"⟩Post\"https://httpbin.org/post\"‿\"{\"\"key\"\": \"\"value\"\"}\"\n#+end_src\n\n*** Response objects\n\nThe response object is a namespace with the following elements:\n- ~code~: the response code.\n- ~headers~: the response headers as a single string, separated by newlines.\n- ~content~: the response content, as raw bytes.\n- ~time~: the time the request took, in seconds.\n- ~redirectCount~: the number of redirects.\n\nIf your endpoint returns text, you can use ~FromBytes~ from\n[[https://github.com/mlochbaum/bqn-libs/blob/master/strings.bqn][bqn-libs/strings.bqn]] to decode UTF-8.\n\n*** Advanced API\n\nFor more fine-grained control on request parameters, you can use the\nadvanced API, which closely mirrors the libcurl API structure.\n\nA session object is created with ~OpenSession~, and can be reused to\nspeed up successive requests by reusing an existing connection.\n\nCreate a request by modifying the session object. Each of the\nfunctions take the session as their right argument, and configuration\ndata as their left argument. They modify the session in-place, but\nalso return it so that they can be chained easily.\n\n- ~url SetURL session~: the request URL.\n- ~headers SetHeaders session~: the request headers, as a list of strings.\n- ~SetVerbose session~: log verbose request data to standard output.\n- ~n SetTimeout session~ and ~n SetTimeoutms timeout~: the request timeout, in seconds or in milliseconds.\n- ~data SetData session~: use a POST request and set the data to send, as a string.\n\nFinally, perform the actual request with ~Perform~, returning the\nresponse object as above.\n\nThe session object can then be reused for subsequent requests,\nmodifying request parameters as needed. It can be reset to its default\nconfiguration using ~ResetSession~, while preserving open connections\nand caches.\n\nA session is terminated, and its memory freed, with ~CloseSession~.\n\nFull example:\n#+begin_src bqn\n⟨\n  OpenSession,CloseSession,\n  SetURL,SetHeaders,SetTimeoutms,\n  Perform,\n⟩←•Import\"curl.bqn\"\n\nsession←⟨\"User-Agent: myapp\"⟩SetHeaders OpenSession @\nr1←Perform \"https://httpbin.org/status/418\"SetURL session\n•Show r1.code\nr2←Perform 500 SetTimeoutms \"https://httpbin.org/ip\"SetURL session\n•Out r2.content\n\nCloseSession session\n#+end_src\n\n** Running tests\n\nRun a local [[https://httpbin.org/][httpbin.org]] instance with Docker:\n#+begin_src sh\ndocker run -p 8080:80 kennethreitz/httpbin\n#+end_src\n\nThe tests can be run with =bqn tests.bqn=.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdlozeve%2Fbqn-curl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdlozeve%2Fbqn-curl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdlozeve%2Fbqn-curl/lists"}