ua_conn_print_header - fill a buffer with all headers

char *ua_conn_print_header(struct ua_conn *conn, char *buf, size_t bufsize)

Fill a buffer with the request header.

Parameters
  • conn – the connection handle

  • buf – the user buffer to be filled

  • bufsize – the user buffer size in bytes

Returns

the user buffer

Example

struct user_agent *ua = ua_init(NULL);
ua_set_url(ua, "https://www.example.com");

struct ua_conn_attr conn_attr = { .method = HTTP_GET };
struct ua_conn *conn = ua_conn_start(ua);
ua_conn_setup(conn, &conn_attr);

ua_conn_add_header(conn, "User-Agent", "my_application");
ua_conn_add_header(conn, "Authorization", "Bearer xyzABC");

char buf[2048];
printf("%s\n", ua_conn_print_header(conn, buf, sizeof(buf)));

ua_conn_stop(conn);
ua_cleanup(ua);