crossroads

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

httpheadersetheader.c (1153B)


      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_setheader (HttpHeader *m, char const *h) {
      9     int i;
     10     char *hname, *cp, *exp;
     11 
     12     hname = xstrdup (h);
     13     if (! (cp = strchr (hname, ':')) ) {
     14 	free (hname);
     15 	return;
     16     }
     17     *cp = 0;
     18 
     19     exp = str_expand_format (h);
     20     for (i = 0; i < m->nheader; i++) {
     21 	if (!m->header[i] || !*m->header[i])
     22 	    continue;
     23 	if (!strncasecmp (m->header[i], hname, strlen(hname))) {
     24 	    free (m->header[i]);
     25 	    msg ("Service %s: setting (replacing) header '%s'",
     26 		 activeservice->name, exp);
     27 	    m->header[i] = exp;
     28 	    free (hname);
     29 	    return;
     30 	}
     31     }
     32 
     33     msg ("Service %s: setting (adding) header '%s'", activeservice->name, exp);
     34     m->header = xrealloc (m->header, (m->nheader + 1) * sizeof(char*));
     35     m->header[m->nheader++] = exp;
     36     free (hname);
     37 }