From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Christophe Fergeau <cfergeau@redhat.com>
Date: Mon, 8 Feb 2016 14:50:50 +0100
Subject: [PATCH] proxy: Remove jsessionid cookie when its value is NULL
---
govirt/ovirt-proxy-private.h | 1 +
govirt/ovirt-proxy.c | 6 ++++++
2 files changed, 7 insertions(+)
diff --git a/govirt/ovirt-proxy-private.h b/govirt/ovirt-proxy-private.h
index 0831785..ab87142 100644
--- a/govirt/ovirt-proxy-private.h
+++ b/govirt/ovirt-proxy-private.h
@@ -37,6 +37,7 @@ struct _OvirtProxyPrivate {
gboolean admin_mode;
OvirtApi *api;
char *jsessionid;
+ SoupCookie *jsessionid_cookie;
char *sso_token;
SoupCookieJar *cookie_jar;
diff --git a/govirt/ovirt-proxy.c b/govirt/ovirt-proxy.c
index a5e9251..f289719 100644
--- a/govirt/ovirt-proxy.c
+++ b/govirt/ovirt-proxy.c
@@ -720,12 +720,18 @@ static void ovirt_proxy_set_session_id(OvirtProxy *proxy, const char *session_id
domain = url;
}
+ if (proxy->priv->jsessionid_cookie != NULL) {
+ soup_cookie_jar_delete_cookie(proxy->priv->cookie_jar,
+ proxy->priv->jsessionid_cookie);
+ proxy->priv->jsessionid_cookie = NULL;
+ }
g_free(proxy->priv->jsessionid);
proxy->priv->jsessionid = g_strdup(session_id);
if (proxy->priv->jsessionid != NULL) {
SoupCookie *cookie;
cookie = soup_cookie_new("JSESSIONID", session_id, domain, "/ovirt-engine/api", -1);
soup_cookie_jar_add_cookie(proxy->priv->cookie_jar, cookie);
+ proxy->priv->jsessionid_cookie = cookie;
}
g_free(url);
}