aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2005-12-12 18:52:08 +0000
committertradke <tradke@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2005-12-12 18:52:08 +0000
commit258b12d17fdc1c2b4359b0626a0498c357e03b9e (patch)
tree61141659a70eba74022e6ae783d7508e4415dc0a
parent8bb001d290d9797f438fe92464d210362434c364 (diff)
Fixed bug in HTTP_CookieGet() so that it really finds a cookie in a HTTP header.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPD/trunk@226 1faa4e14-9dd3-4be0-9f0e-ffe519881164
-rw-r--r--src/Cookies.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/Cookies.c b/src/Cookies.c
index 0558006..559c052 100644
--- a/src/Cookies.c
+++ b/src/Cookies.c
@@ -160,35 +160,33 @@ int HTTP_CookieCancel(httpRequest *request,
char *HTTP_CookieGet(httpRequest *request, const char *cookie_name)
{
char *retval = NULL;
- const String *COOKIE = String_Make("cookie");
+ String *attribute = String_Make("Cookie");
String *header = String_New();
+
/* Get the cookie header */
- if( HTTP_GetHeaderValueString( request, COOKIE, header ) )
+ if( HTTP_GetHeaderValueString( request, attribute, header ) )
{
String *name = String_Make( cookie_name );
String *value = String_New();
size_t index = 0;
- /* Search for name=value */
- while( SetNextToken( header, value, ";", index ) )
+ /* Search for "name=" */
+ ConcatCString (name, "=");
+ if (FindStringFrom (header, name, &index))
{
- size_t position = 0;
- if( FindStringFrom( value, name, &position )
- && position == 0 )
+ /* cut "value" at the next ';' char or at EOS */
+ size_t position = index + StringLength (name);
+ if (FindCharFrom (header, ';', &position))
{
- if( FindCharFrom( value, '=', &position )
- && position == Length( name ) )
- {
- TrimLeading( value, position + 1 );
- retval = Util_Strdup( GetBuffer( value ) );
- }
- break;
+ TrimLeading (header, position);
}
+ retval = Util_Strdup (GetBuffer (header) + index);
}
String_Delete(name);
String_Delete(value);
}
String_Delete(header);
+ String_Delete(attribute);
return retval;
}