Re: segfaults calling soup_cookie_new with cookie domain = NULL



On 27/03/2009 16:45, Dan Winship wrote:
Jérémy Lal wrote:
Hi,
using libsoup2.4 (2.25) and libsoup2.4 (2.26.0)
i just got a segfault doing that :

const char* fDomain = NULL;
const char* fPath = NULL;
SoupCookie* fCookie = soup_cookie_new(cookieName, cookieValue, fDomain,
fPath, SOUP_COOKIE_MAX_AGE_ONE_HOUR);
soup_cookie_jar_add_cookie(fCookieJar, fCookie);

no segfault with
fDomain = "";

Yeah... the documentation is wrong. You're not really allowed to have a
cookie with a NULL domain. soup_cookie_new() lets you do this, but as
you noticed, other methods assume all cookies have a domain set. Note
that the cookie "domain" is not completely equivalent to the "domain"
attribute in a Set-Cookie header; even if the Set-Cookie had no domain
attribute, the cookie still needs to have a domain value set, containing
the hostname that the cookie came from.
indeed,
i forgot to mention that the problem was in the documentation, not in the code

Why are you creating your own cookies by hand, btw?
good question, as i'm having troubles here :
in a small program, i'm using webkit to load a php page which is served on localhost,
so i call webkit_web_view_load_uri function.
i want to populate the http headers with a Cookie: field
so that the php page gets the cookie.
The only object i found exposed by webkit was SoupSession (webkit_get_default_session).
The following code hangs, and i don't get why. I'm new to gtk and stuff.
What's weird is that it does not hang if i set domain != "localhost"
But in that case the php page won't get the cookie, so it's useless.


SoupSession* fSession = webkit_get_default_session();
SoupCookieJar* fCookieJar = soup_cookie_jar_new();
soup_session_add_feature(fSession, SOUP_SESSION_FEATURE(fCookieJar));
SoupCookie* fCookie = soup_cookie_new(cookiename, cookievalue, "localhost", "/", 1);
soup_cookie_jar_add_cookie(fCookieJar, fCookie);

(then, i call
webkit_web_view_load_uri(webview, gURL);
gtk_main();)

i know i'm probably wrong doing this, but i'm a bit short of examples.
Jérémy.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]