summaryrefslogtreecommitdiff
path: root/rest
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2016-07-18 10:33:23 +0200
committerChristophe Fergeau <cfergeau@redhat.com>2016-07-19 13:22:15 +0200
commitd6bd5d7b4c4b71e8c256729ae1954e3f27855a00 (patch)
tree14675f1a8226c2a3ae2eff2154361ee0a2c6fb5e /rest
parenta6216a8553235f1a6aa91ae6a0843b8ffb11d8f8 (diff)
downloadlibrest-d6bd5d7b4c4b71e8c256729ae1954e3f27855a00.tar.gz
RestProxyCall: Make sure _sync reliably sets error_out
Currently rest_proxy_call_sync (and everything else using prepare_message) might return FALSE without setting @error at all. Add two new error codes to indicate the possible problems and reliably set the error if something went wrong.
Diffstat (limited to 'rest')
-rw-r--r--rest/rest-proxy-call.c22
-rw-r--r--rest/rest-proxy.h4
2 files changed, 24 insertions, 2 deletions
diff --git a/rest/rest-proxy-call.c b/rest/rest-proxy-call.c
index 2cd867a..9384b5b 100644
--- a/rest/rest-proxy-call.c
+++ b/rest/rest-proxy-call.c
@@ -753,6 +753,10 @@ prepare_message (RestProxyCall *call, GError **error_out)
{
g_free (content);
g_free (content_type);
+ g_set_error_literal (error_out,
+ REST_PROXY_ERROR,
+ REST_PROXY_ERROR_BINDING_REQUIRED,
+ "URL is unbound");
return NULL;
}
@@ -775,6 +779,10 @@ prepare_message (RestProxyCall *call, GError **error_out)
if (!set_url (call))
{
+ g_set_error_literal (error_out,
+ REST_PROXY_ERROR,
+ REST_PROXY_ERROR_BINDING_REQUIRED,
+ "URL is unbound");
return NULL;
}
@@ -786,8 +794,14 @@ prepare_message (RestProxyCall *call, GError **error_out)
g_hash_table_unref (hash);
- if (!message)
- return NULL;
+ if (!message) {
+ g_set_error (error_out,
+ REST_PROXY_ERROR,
+ REST_PROXY_ERROR_URL_INVALID,
+ "URL '%s' is not valid",
+ priv->url);
+ return NULL;
+ }
} else {
SoupMultipart *mp;
@@ -822,6 +836,10 @@ prepare_message (RestProxyCall *call, GError **error_out)
if (!set_url (call))
{
soup_multipart_free (mp);
+ g_set_error_literal (error_out,
+ REST_PROXY_ERROR,
+ REST_PROXY_ERROR_BINDING_REQUIRED,
+ "URL is unbound");
return NULL;
}
diff --git a/rest/rest-proxy.h b/rest/rest-proxy.h
index d341403..d882dea 100644
--- a/rest/rest-proxy.h
+++ b/rest/rest-proxy.h
@@ -97,6 +97,8 @@ struct _RestProxyClass {
* @REST_PROXY_ERROR_SSL: SSL
* @REST_PROXY_ERROR_IO: Input/Output
* @REST_PROXY_ERROR_FAILED: Failure
+ * @REST_PROXY_ERROR_URL_INVALID: Invalid URL
+ * @REST_PROXY_ERROR_BINDING_REQUIRED: URL requires binding
* @REST_PROXY_ERROR_HTTP_MULTIPLE_CHOICES: HTTP/Multiple choices
* @REST_PROXY_ERROR_HTTP_MOVED_PERMANENTLY: HTTP/Moved permanently
* @REST_PROXY_ERROR_HTTP_FOUND: HTTP/Found
@@ -139,6 +141,8 @@ typedef enum {
REST_PROXY_ERROR_SSL,
REST_PROXY_ERROR_IO,
REST_PROXY_ERROR_FAILED,
+ REST_PROXY_ERROR_URL_INVALID,
+ REST_PROXY_ERROR_BINDING_REQUIRED,
REST_PROXY_ERROR_HTTP_MULTIPLE_CHOICES = 300,
REST_PROXY_ERROR_HTTP_MOVED_PERMANENTLY = 301,