struct _ZakCgiSessionPrivate
{
ZakCgiMain *zakcgimain;
+ gchar *base_uri;
gchar *sid;
GFile *gfile;
GKeyFile *kfile;
{
ZakCgiSessionPrivate *priv = ZAK_CGI_SESSION_GET_PRIVATE (zak_cgi_session);
- priv->zakcgimain;
+ priv->zakcgimain = NULL;
+ priv->base_uri = NULL;
}
/**
* zak_cgi_session_new:
* @zakcgimain:
+ * @base_uri:
*
* Returns: the newly created #ZakCgiSession object.
*/
ZakCgiSession
-*zak_cgi_session_new (ZakCgiMain *zakcgimain)
+*zak_cgi_session_new (ZakCgiMain *zakcgimain,
+ const gchar *base_uri)
{
GHashTable *ht_cookies;
priv = ZAK_CGI_SESSION_GET_PRIVATE (zak_cgi_session);
priv->zakcgimain = zakcgimain;
+ if (base_uri != NULL)
+ {
+ priv->base_uri = g_strdup (base_uri);
+ }
ht_cookies = zak_cgi_main_get_cookies (priv->zakcgimain);
priv->sid = g_hash_table_lookup (ht_cookies, "ZAKCGISID");
GError *error;
GFileIOStream *iostream;
+ guint32 i;
+ gchar *tmp;
+
+ GHashTable *ht_env;
+
ZakCgiSessionPrivate *priv = ZAK_CGI_SESSION_GET_PRIVATE (session);
if (priv->sid == NULL)
{
/* create new random name */
- guint32 i;
- gchar *tmp;
i = g_random_int ();
tmp = g_strdup_printf ("%d", i);
-
+
priv->sid = g_compute_checksum_for_string (G_CHECKSUM_MD5,
tmp,
strlen (tmp));
g_object_unref (iostream);
}
- ret = zak_cgi_main_set_cookie ("ZAKCGISID", priv->sid, NULL, NULL, NULL, FALSE, FALSE);
+ ht_env = zak_cgi_main_get_env (priv->zakcgimain);
+
+ ret = zak_cgi_main_set_cookie ("ZAKCGISID", priv->sid, NULL, NULL,
+ priv->base_uri != NULL ? priv->base_uri : g_value_get_string (g_hash_table_lookup (ht_env, "CONTEXT_PREFIX")),
+ FALSE, FALSE);
}
else
{
GType zak_cgi_session_get_type (void);
-ZakCgiSession *zak_cgi_session_new (ZakCgiMain *zakcgimain);
+ZakCgiSession *zak_cgi_session_new (ZakCgiMain *zakcgimain,
+ const gchar *base_uri);
gchar *zak_cgi_session_get_header (ZakCgiSession *session);
int
main (int argc, char *argv[])
{
+ gchar *env;
ZakCgiUrl *url;
GString *str;
"<body>\n"
"FROM INIT<br/><br/>\n");
+ env = zak_cgi_main_dump_env (NULL);
+
url = zak_cgi_url_new (NULL);
zak_cgi_url_connect (url, "/(?<controller>[a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)", (ZakCgiUrlConnectedFunction)hook, str);
zak_cgi_url_dispatch (url);
- g_string_append_printf (str, "</body>\n");
+ g_string_append_printf (str, "<hr/>%s</body>\n", env);
zak_cgi_main_out (NULL, str->str);
g_string_free (str, TRUE);