crossroads

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

httpheaderappendheader.c (1299B)


      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 void http_header_appendheader (HttpHeader *m, char const *h) {
      9     char *hname, *cp, *exp;
     10     int i;
     11     
     12     hname = xstrdup (h);
     13     if (! (cp = strchr (hname, ':')) ) {
     14 	free (hname);
     15 	return;
     16     }
     17     *cp = 0;
     18     cp++;
     19 
     20     while (is_space (*cp) || *cp == ':')
     21 	cp++;
     22     exp = str_expand_format (cp);
     23     
     24     for (i = 0; i < m->nheader; i++) {
     25 	if (!m->header[i] || !*m->header[i])
     26 	    continue;
     27 	// msg ("Append header: comparing '%s' to '%s'", hname, m->header[i]);
     28 	if (!strncasecmp (m->header[i], hname, strlen(hname))) {
     29 	    m->header[i] = xstrcat (m->header[i], "; ");
     30 	    m->header[i] = xstrcat (m->header[i], exp);
     31 	    /* msg ("Service %s: appending (after existing) header, now '%s'",
     32 	       activeservice->name, m->header[i]); */
     33 	    free (hname);
     34 	    return;
     35 	}
     36     }
     37 
     38     /*  msg ("Service %s: appending (setting) header '%s'",
     39 	activeservice->name, h); */
     40     
     41     http_header_addheader (m, h);
     42 }