crossroads

Git mirror of https://crossroads.e-tunity.com/
git clone git://git.finwo.net/app/crossroads
Log | Files | Refs

httpheaderhascookie.c (1110B)


      1 /*************************************************************************
      2  * This file is part of Crosroads 1.23, a load balancer and fail over
      3  * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL.
      4  * Visit http://crossroads.e-tunity.com for information.
      5  *************************************************************************/
      6 #include "crossroads.h"
      7 
      8 int http_header_hascookie (HttpHeader *m, char const *cookie) {
      9     unsigned char const *val;
     10     char *cp, *buf;
     11     
     12     if (!cookie)
     13 	return (0);
     14     if (! (val = http_header_val (m, "cookie")) ) {
     15 	msg ("Service %s: no cookies in HTTP message", activeservice->name);
     16 	return (0);
     17     }
     18 
     19     buf = xstrdup ((char const *) val);
     20     for (cp = buf; cp && *cp; cp = strchr (cp, ';')) {
     21 	while (*cp == ';' || *cp == ' ')
     22 	    cp++;
     23 	if (!strncmp (cp, cookie, strlen (cookie))) {
     24 	    msg ("Service %s: found cookie '%s' in '%s'",
     25 		 activeservice->name, cookie, buf);
     26 	    free (buf);
     27 	    return (1);
     28 	}
     29     }
     30     msg ("Service %s: cookie '%s' not present in '%s'",
     31 	 activeservice->name, cookie, buf);
     32     free (buf);
     33     return (0);
     34 }