src/proto_http.c
static char *
extract_cookie_value(char *hdr, const char *hdr_end,
		  char *cookie_name, size_t cookie_name_l, int list,
		  char **value, int *value_l)
{
	char *equal, *att_end, *att_beg, *val_beg, *val_end;
	char *next;

	/* we search at least a cookie name followed by an equal, and more
	 * generally something like this :
	 * Cookie:    NAME1  =  VALUE 1  ; NAME2 = VALUE2 ; NAME3 = VALUE3\r\n
	 */
	for (att_beg = hdr; att_beg + cookie_name_l + 1 < hdr_end; att_beg = next + 1) {
		/* Iterate through all cookies on this line */

		while (att_beg < hdr_end && http_is_spht[(unsigned char)*att_beg])
			att_beg++;

		/* find att_end : this is the first character after the last non
		 * space before the equal. It may be equal to hdr_end.
		 */
		equal = att_end = att_beg;

		while (equal < hdr_end) {
			if (*equal == '=' || *equal == ';' || (list && *equal == ','))
				break;
			if (http_is_spht[(unsigned char)*equal++])
				continue;
			att_end = equal;
		}

		/* here, <equal> points to '=', a delimitor or the end. <att_end>
		 * is between <att_beg> and <equal>, both may be identical.
		 */

		/* look for end of cookie if there is an equal sign */
		if (equal < hdr_end && *equal == '=') {
			/* look for the beginning of the value */
			val_beg = equal + 1;
			while (val_beg < hdr_end && http_is_spht[(unsigned char)*val_beg])
				val_beg++;

			/* find the end of the value, respecting quotes */
			next = find_cookie_value_end(val_beg, hdr_end);

			/* make val_end point to the first white space or delimitor after the value */
			val_end = next;
			while (val_end > val_beg && http_is_spht[(unsigned char)*(val_end - 1)])
				val_end--;
		} else {
			val_beg = val_end = next = equal;
		}

		/* We have nothing to do with attributes beginning with '$'. However,
		 * they will automatically be removed if a header before them is removed,
		 * since they're supposed to be linked together.
		 */
		if (*att_beg == '$')
			continue;

		/* Ignore cookies with no equal sign */
		if (equal == next)
			continue;

		/* Now we have the cookie name between att_beg and att_end, and
		 * its value between val_beg and val_end.
		 */

		if (att_end - att_beg == cookie_name_l &&
		    memcmp(att_beg, cookie_name, cookie_name_l) == 0) {
			/* let's return this value and indicate where to go on from */
			*value = val_beg;
			*value_l = val_end - val_beg;
			return next + 1;
		}

		/* Set-Cookie headers only have the name in the first attr=value part */
		if (!list)
			break;
	}

	return NULL;
}
/* Try to find the next occurrence of a cookie name in a cookie header value.
 * The lookup begins at <hdr>. The pointer and size of the next occurrence of
 * the cookie value is returned into *value and *value_l, and the function
 * returns a pointer to the next pointer to search from if the value was found.
 * Otherwise if the cookie was not found, NULL is returned and neither value
 * nor value_l are touched. The input <hdr> string should first point to the
 * header's value, and the <hdr_end> pointer must point to the first character
 * not part of the value. <list> must be non-zero if value may represent a list
 * of values (cookie headers). This makes it faster to abort parsing when no
 * list is expected.
 */
Try to find the next occurrence of a cookie name in a cookie header value.
The lookup begins at . The pointer and size of the next occurrence of
the cookie value is returned into *value and *value_l, and the function
returns a pointer to the next pointer to search from if the value was found.
Otherwise if the cookie was not found, NULL is returned and neither value
nor value_l are touched. The input  string should first point to the
header's value, and the  pointer must point to the first character
not part of the value.  must be non-zero if value may represent a list
of values (cookie headers). This makes it faster to abort parsing when no
list is expected.
Try to find the next occurrence of a cookie name in a cookie header value . The lookup begins at . The pointer and size of the next occurrence of the cookie value is returned into * value and * value_l and the function returns a pointer to the next pointer to search from if the value was found . Otherwise if the cookie was not found NULL is returned and neither value nor value_l are touched . The input string should first point to the header ' s value and the pointer must point to the first character not part of the value . must be non - zero if value may represent a list of values ( cookie headers ) . This makes it faster to abort parsing when no list is expected .
static char *
extract_cookie_value(char *hdr, const char *hdr_end,
		  char *cookie_name, size_t cookie_name_l, int list,
		  char **value, int *value_l)
{
	char *equal, *att_end, *att_beg, *val_beg, *val_end;
	char *next;
	for (att_beg = hdr; att_beg + cookie_name_l + 1 < hdr_end; att_beg = next + 1) {
		while (att_beg < hdr_end && http_is_spht[(unsigned char)*att_beg])
			att_beg++;
		equal = att_end = att_beg;
		while (equal < hdr_end) {
			if (*equal == '=' || *equal == ';' || (list && *equal == ','))
				break;
			if (http_is_spht[(unsigned char)*equal++])
				continue;
			att_end = equal;
		}
		if (equal < hdr_end && *equal == '=') {
			val_beg = equal + 1;
			while (val_beg < hdr_end && http_is_spht[(unsigned char)*val_beg])
				val_beg++;
			next = find_cookie_value_end(val_beg, hdr_end);
			val_end = next;
			while (val_end > val_beg && http_is_spht[(unsigned char)*(val_end - 1)])
				val_end--;
		} else {
			val_beg = val_end = next = equal;
		}
		if (*att_beg == '$')
			continue;
		if (equal == next)
			continue;
		if (att_end - att_beg == cookie_name_l &&
		    memcmp(att_beg, cookie_name, cookie_name_l) == 0) {
			*value = val_beg;
			*value_l = val_end - val_beg;
			return next + 1;
		}
		if (!list)
			break;
	}
	return NULL;
}
static char * extract_cookie_value ( char * hdr , const char * hdr_end , char * cookie_name , size_t cookie_name_l , int list , char * * value , int * value_l ) { char * equal , * att_end , * att_beg , * val_beg , * val_end ; char * next ; for ( att_beg = hdr ; att_beg + cookie_name_l + 1 < hdr_end ; att_beg = next + 1 ) { while ( att_beg < hdr_end && http_is_spht [ ( unsigned char ) * att_beg ] ) att_beg ++ ; equal = att_end = att_beg ; while ( equal < hdr_end ) { if ( * equal == ' ' || * equal == ' ' || ( list && * equal == ' ' ) ) break ; if ( http_is_spht [ ( unsigned char ) * equal ++ ] ) continue ; att_end = equal ; } if ( equal < hdr_end && * equal == ' ' ) { val_beg = equal + 1 ; while ( val_beg < hdr_end && http_is_spht [ ( unsigned char ) * val_beg ] ) val_beg ++ ; next = find_cookie_value_end ( val_beg , hdr_end ) ; val_end = next ; while ( val_end > val_beg && http_is_spht [ ( unsigned char ) * ( val_end - 1 ) ] ) val_end -- ; } else { val_beg = val_end = next = equal ; } if ( * att_beg == ' ' ) continue ; if ( equal == next ) continue ; if ( att_end - att_beg == cookie_name_l && memcmp ( att_beg , cookie_name , cookie_name_l ) == 0 ) { * value = val_beg ; * value_l = val_end - val_beg ; return next + 1 ; } if ( ! list ) break ; } return NULL ; }
Try to find the next occurrence of a cookie name in a cookie header value.
Try to find the next occurrence of a cookie name in a cookie header value .
/* we search at least a cookie name followed by an equal, and more
	 * generally something like this :
	 * Cookie:    NAME1  =  VALUE 1  ; NAME2 = VALUE2 ; NAME3 = VALUE3\r\n
	 */ /* Iterate through all cookies on this line */ /* find att_end : this is the first character after the last non
		 * space before the equal. It may be equal to hdr_end.
		 */ /* here, <equal> points to '=', a delimitor or the end. <att_end>
		 * is between <att_beg> and <equal>, both may be identical.
		 */ /* look for end of cookie if there is an equal sign */ /* look for the beginning of the value */ /* find the end of the value, respecting quotes */ /* make val_end point to the first white space or delimitor after the value */ /* We have nothing to do with attributes beginning with '$'. However,
		 * they will automatically be removed if a header before them is removed,
		 * since they're supposed to be linked together.
		 */ /* Ignore cookies with no equal sign */ /* Now we have the cookie name between att_beg and att_end, and
		 * its value between val_beg and val_end.
		 */ /* let's return this value and indicate where to go on from */ /* Set-Cookie headers only have the name in the first attr=value part */