aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2006-02-27 15:19:16 +0000
committertradke <tradke@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2006-02-27 15:19:16 +0000
commit984a62e44b59385521689e8db154e4f0a52bd5d1 (patch)
tree7c2994265c286799468a5f0991143794335e553e
parentd00790842557372e5b0ba357356961c1e59cbc40 (diff)
HTTP_CookieGet() should return just the value of a cookie, not the entire
"<name>=<value>" string. git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPD/trunk@229 1faa4e14-9dd3-4be0-9f0e-ffe519881164
-rw-r--r--src/Cookies.c22
1 files 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 "<name>=" */
if (FindStringFrom (header, name, &value_start))
{
/* truncate "<value>" 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;
}
/********************************************************************