[librest] Ignore '/' at beginning of REST function
- From: Christophe Fergeau <teuf src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librest] Ignore '/' at beginning of REST function
- Date: Tue, 26 Aug 2014 09:15:29 +0000 (UTC)
commit d54c36cc22c365bd21936365f7c9410899ad3ec1
Author: Christophe Fergeau <cfergeau redhat com>
Date: Fri Apr 25 15:33:40 2014 +0200
Ignore '/' at beginning of REST function
When building the HTTP URL to access for a REST operation,
RestProxyCall::prepare_message, a '/' at the end of the base URL
is ignored, but a '/' at the beginning of the REST function is not.
When interacting with the oVirt REST API, I often end up building calls
with for example 'https://ovirt.example.com' as the base URI, and '/api/vms/'
as the function, which then leads to an URI with 2 '/':
'https://ovirt.example.com//api/vms'
https://bugzilla.gnome.org/show_bug.cgi?id=728952
rest/rest-proxy-call.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/rest/rest-proxy-call.c b/rest/rest-proxy-call.c
index a264f2e..fbf4880 100644
--- a/rest/rest-proxy-call.c
+++ b/rest/rest-proxy-call.c
@@ -748,7 +748,8 @@ prepare_message (RestProxyCall *call, GError **error_out)
/* FIXME: Perhaps excessive memory duplication */
if (priv->function)
{
- if (g_str_has_suffix (bound_url, "/"))
+ if (g_str_has_suffix (bound_url, "/")
+ || g_str_has_prefix (priv->function, "/"))
{
priv->url = g_strdup_printf ("%s%s", bound_url, priv->function);
} else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]