CURL integration

Argentum programs can interact with web servers:

using httpClient{ get, Response }

// The httpClient module always performs its operation asynchronously
// so the application needs to have a global state:
class App {}
app = App;

// Perform request
get("", app.&onFetched(r Response){
    log("Result code={r.status}: response size={r.body.capacity()}");

    // Quit from application

The httpClient module features:

  • It performs all operations on a separate thread.
  • It uses curl-multy, so multiple simultaneous requests work on a single thread sharing caches and resources.
  • If some listener dies, all its operations get cancelled automatically.
  • The httpClient_Request object allows to customize requests by adding different verbs, request headers etc.
  • The httpClient_Response object allows to get access to response headers, status code, response body and all request data.

Leave a Reply

Your email address will not be published. Required fields are marked *