return r;
}
+static int td_source_request_failed(td_ctx* ctx, int code, td_file* file, void* data) {
+ td_source* self = data;
+ int r;
+
+ switch (code) {
+ case CURLE_OK:
+ r = 0;
+ break;
+
+ // For unrecoverable errors, we will disable the source straight away
+ case CURLE_UNSUPPORTED_PROTOCOL:
+ case CURLE_NOT_BUILT_IN:
+ case CURLE_RANGE_ERROR:
+ return td_source_disable(self);
+
+ // Invalid requests
+ case CURLE_URL_MALFORMAT:
+ r = -EINVAL;
+ break;
+
+ // Failed to connect
+ case CURLE_COULDNT_CONNECT:
+ r = -ECONNREFUSED;
+ break;
+
+ // Handle anything else that is unknown
+ default:
+ r = -EINVAL;
+ break;
+ }
+
+ // Run the error detection
+ return td_source_error_detection(self, r, 0);
+}
+
int td_source_create_request(td_source* self, td_request** request) {
td_client* client = NULL;
int r;
if (r < 0)
goto ERROR;
+ // Set the failure callback
+ td_request_on_failure(*request, td_source_request_failed, self);
+
ERROR:
if (client)
td_client_unref(client);