Dynamically creating strings in inline c for use in the VRT_SetHdr function
    Paul A. Procacci 
    pprocacci at datapipe.com
       
    Tue Oct 30 02:05:51 CET 2012
    
    
  
> Hi all,
Hi.
> Firstly, Is there a way to create the header string dynamically. I
> know the header string has to be in the format "\020X-Forwarded-For:",
> it has to start with the length of the string in octal, But if I'm
> creating the header name dynamically, Say if i wanted to create
> separate headers based of GeoIP data or something similar, How could I
> go about creating the string so It matches the format?
Here is one way:
###############################################
  char *str = "X-Header: test";
  char *header;
  asprintf(&header, "\\0%o%s", strlen(str), str);
  # Make sure to check return value, etc.
###############################################
> And secondly, purely out of interest, Could someone explain why the
> header is prefixed with its length in octal? Does it have something to
> do with correctly setting the amount of memory needed?
I do not know the reasoning.
~Paul
________________________________
This message may contain confidential or privileged information. If you are not the intended recipient, please advise us immediately and delete this message. See http://www.datapipe.com/legal/email_disclaimer/ for further information on confidentiality and the risks of non-secure electronic communication. If you cannot access these links, please notify us by reply message and we will send the contents to you.
    
    
More information about the varnish-misc
mailing list