ua_conn_reset - reset a connection for immediate reuse#
-
void ua_conn_reset(struct ua_conn *conn)#
Reset a connection handle fields.
Warning
this won’t deactivate the handle, for that purpose check ua_conn_stop()
- Parameters:
conn – connection handle to be reset
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);
bool retry = true;
while (retry) {
if (ua_conn_perform(conn) != ORCA_OK)
break; /* internal error */
struct ua_info info = { 0 };
ua_info_extract(conn, &info);
if (info.code >= 200 && info.code < 300) {
retry = false;
}
else {
/* transfer failed, reset conn's and try again */
ua_conn_reset(conn);
}
ua_info_cleanup(&info);
}
ua_conn_stop(conn);
ua_cleanup(ua);