ua_info_get_header - get response header’s value from field#
-
struct sized_buffer ua_info_get_header(struct ua_info *info, char field[])#
Get a value’s from the response header.
- Parameters:
info – handle containing information on previous request
field – the header field to fetch the value
- Returns:
a sized_buffer containing the field’s value
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);
if (ORCA_OK == ua_conn_perform(conn)) {
struct ua_info info = { 0 };
ua_info_extract(conn, &info);
if (info.code >= 200 && info.code < 300) {
struct sized_buffer date = ua_conn_get_header(&info, "Date");
printf("Finish at %.*s!\n", (int)date.size, date.start);
}
ua_info_cleanup(&info);
ua_conn_stop(conn);
}
ua_conn_stop(conn);
ua_cleanup(ua);