ua_set_opt - set connection’s default configuration#

void ua_set_opt(struct user_agent *ua, void *data, void (*callback)(struct ua_conn *conn, void *data))#

Callback to be called on each libcurl’s easy handle initialization.

Parameters:
  • ua – the User-Handle created with ua_init()

  • data – user data to be passed along to callback

  • callback – the user callback

Example#

void default_config(struct ua_conn *conn, void *data)
{
  ua_conn_add_header(conn, "User-Agent", "my_application");
  ua_conn_add_header(conn, "Authorization", "Bearer xyzABC");
}

int main(void)
{
  struct user_agent *ua = ua_init(NULL);
  ua_set_url(ua, "https://www.example.com");
  ua_set_opt(ua, NULL, &default_config);

  struct ua_conn_attr conn_attr = { .method = HTTP_GET };

  ua_easy_run(ua, NULL, NULL, &conn_attr);

  ua_cleanup(ua);
}