[prev in list] [next in list] [prev in thread] [next in thread] 

List:       varnish-misc
Subject:    Re: Dynamically creating strings in inline c for use in the VRT_SetHdr function
From:       "Paul A. Procacci" <pprocacci () datapipe ! com>
Date:       2012-10-30 1:05:51
Message-ID: 20121030010551.GB8791 () nat ! myhome
[Download RAW message or body]

> 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.

_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic