aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Savkov <asavkov@redhat.com>2015-10-07 15:13:34 +0200
committerdequis <dx@dxzone.com.ar>2015-10-08 02:10:19 -0300
commit0b0bb4c68a1c87b8f77f266ea8e836758203f53e (patch)
tree4fb442d0354259c13f15aa2e2c52682f82d60ac3
parent098b4309df5fc7d55b2fee5229f3a0215d3cd3a5 (diff)
Allow NULL callback functions in http_dorequest
Check callback function supplied to http_dorequest and only run it if it is not NULL. While it is not the usual case there are some times when there is no need to check the results of a http request. Using a NULL pointer is much more convenient than creating noop functions.
-rw-r--r--lib/http_client.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/http_client.c b/lib/http_client.c
index 1dc5947a..9110b70a 100644
--- a/lib/http_client.c
+++ b/lib/http_client.c
@@ -161,7 +161,9 @@ error:
req->status_string = g_strdup("Error while writing HTTP request");
}
- req->func(req);
+ if (req->func != NULL) {
+ req->func(req);
+ }
http_free(req);
return FALSE;
}
@@ -298,7 +300,9 @@ cleanup:
req->status_string ? req->status_string : "NULL");
}
- req->func(req);
+ if (req->func != NULL) {
+ req->func(req);
+ }
http_free(req);
return FALSE;
}
@@ -411,7 +415,7 @@ static http_ret_t http_process_data(struct http_request *req, const char *buffer
req->body_size = req->sblen - pos;
}
- if ((req->flags & HTTPC_STREAMING) && req->reply_body) {
+ if ((req->flags & HTTPC_STREAMING) && req->reply_body && req->func != NULL) {
req->func(req);
}