From 984a62e44b59385521689e8db154e4f0a52bd5d1 Mon Sep 17 00:00:00 2001 From: tradke Date: Mon, 27 Feb 2006 15:19:16 +0000 Subject: HTTP_CookieGet() should return just the value of a cookie, not the entire "=" string. git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPD/trunk@229 1faa4e14-9dd3-4be0-9f0e-ffe519881164 --- src/Cookies.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/Cookies.c b/src/Cookies.c index 598115a..ba68e68 100644 --- a/src/Cookies.c +++ b/src/Cookies.c @@ -146,20 +146,15 @@ int HTTP_CookieCancel(httpRequest *request, @routine HTTP_CookieGet @date Mon Sep 18 22:43:20 2000 @author Tom Goodale - @desc - Gets the value of a cookie from a request. - @enddesc - @calls - @calledby - @history - - @endhistory - + @desc + Gets the value of a cookie from a request. + The allocated return string must be freed by the caller. + @enddesc @@*/ char *HTTP_CookieGet(httpRequest *request, const char *cookie_name) { - char *retval = NULL; + char *cookie_value = NULL; String *attribute = String_Make("Cookie"); String *header = String_New(); @@ -169,24 +164,25 @@ char *HTTP_CookieGet(httpRequest *request, const char *cookie_name) size_t value_start = 0; String *name = String_Make( cookie_name ); ConcatCString (name, "="); - + /* Search for "=" */ if (FindStringFrom (header, name, &value_start)) { /* truncate "" at the next ';' char */ size_t value_end = value_start + StringLength (name); + value_start = value_end; if (FindCharFrom (header, ';', &value_end)) { StringTruncate (header, value_end); } - retval = Util_Strdup (GetBuffer (header) + value_start); + cookie_value = Util_Strdup (GetBuffer (header) + value_start); } String_Delete(name); } String_Delete(header); String_Delete(attribute); - return retval; + return cookie_value; } /******************************************************************** -- cgit v1.2.3