]> git.pld-linux.org Git - packages/pound.git/blame - MultipleAddHeaderHonored.diff
- cosmetics
[packages/pound.git] / MultipleAddHeaderHonored.diff
CommitLineData
1ec54a15
ER
1honour AddHeader specified multiple times
2
3http://www.apsis.ch/pound/pound_list/index_html?query=addheader
4http://www.apsis.ch/pound/pound_list/archive/2011/2011-11/1321393308000#1321393308000
5
6AddHeader directive honored
7
8Francisco Ruiz <francisco.ruiz(at)juntaextremadura.es> 2011-11-15 22:41:48 [ SNIP ]
9 Hi,
10
11I send a patch to the list so that it can be considered and merged to
12the main code if accepted.
13
14We need to add several headers to the request but it seems that
15AddHeader just honors the last occurrence of the directive. Even more,
16several AddHeader directives doesn't rise an error or warning. All of
17them are processed and the string created with previus strdup() call
18seems not to be freed.
19
20The patch sent:
21 * modify config.c to concatenate all the headers in the LISTENER
22struct member add_head with the needed "\r\n".
23 * modify the comment to LISTENER struct member add_head to reflect
24that AddHeader works also with HTTP an not only HTTPS, in pound.h
25 * modify man page pound.8 to reflect the changes.
26
27I hope it can be of any help for others.
28
29On the other hand, I would like to know about the patch that someone
30send to the list to get sticky sessions by injecting cookies in the
31replies to client, as other commercial products do. Are there any plans
32to merge it?
33
34Thanks for pound and to all the community arround it.
35
36--
37Francisco Ruiz
38francisco.ruiz(at)juntaextremadura.es
39
40Ahorrar papel protege el medio ambiente
fd7feb9b
ER
41--- Pound-2.5/config.c 2011-12-09 21:06:52.351470209 +0200
42+++ Pound-2.5/config.c 2011-12-09 21:06:52.351470209 +0200
1ec54a15
ER
43@@ -625,6 +625,7 @@
44 parse_HTTP(void)
45 {
46 char lin[MAXBUF];
47+ char *ah;
48 LISTENER *res;
49 SERVICE *svc;
50 MATCHER *m;
fd7feb9b 51@@ -719,8 +720,19 @@
1ec54a15
ER
52 conf_err("HeadRemove bad pattern - aborted");
53 } else if(!regexec(&AddHeader, lin, 4, matches, 0)) {
54 lin[matches[1].rm_eo] = '\0';
55- if((res->add_head = strdup(lin + matches[1].rm_so)) == NULL)
56- conf_err("AddHeader config: out of memory - aborted");
57+ if (res->add_head == NULL) {
58+ if ((ah = malloc (strlen(lin + matches[1].rm_so) + 1)) == NULL)
59+ conf_err("AddHeader config: out of memory - aborted");
60+ sprintf(ah, "%s", lin + matches[1].rm_so);
61+ }
62+ else {
63+ if ((ah = malloc (strlen(res->add_head) + strlen(lin + matches[1].rm_so) + 1)) == NULL)
64+ conf_err("AddHeader config: out of memory - aborted");
65+ sprintf(ah, "%s\r\n%s", res->add_head, lin + matches[1].rm_so);
66+ }
fd7feb9b
ER
67+ if (res->add_head)
68+ free(res->add_head);
1ec54a15
ER
69+ res->add_head = ah;
70 } else if(!regexec(&RewriteLocation, lin, 4, matches, 0)) {
71 res->rewr_loc = atoi(lin + matches[1].rm_so);
72 } else if(!regexec(&RewriteDestination, lin, 4, matches, 0)) {
fd7feb9b 73@@ -772,6 +785,7 @@
1ec54a15
ER
74 parse_HTTPS(void)
75 {
76 char lin[MAXBUF];
77+ char *ah;
78 LISTENER *res;
79 SERVICE *svc;
80 MATCHER *m;
fd7feb9b 81@@ -902,8 +916,19 @@
1ec54a15
ER
82 }
83 } else if(!regexec(&AddHeader, lin, 4, matches, 0)) {
84 lin[matches[1].rm_eo] = '\0';
85- if((res->add_head = strdup(lin + matches[1].rm_so)) == NULL)
86- conf_err("AddHeader config: out of memory - aborted");
87+ if (res->add_head == NULL) {
88+ if ((ah = malloc (strlen(lin + matches[1].rm_so) + 1)) == NULL)
89+ conf_err("AddHeader config: out of memory - aborted");
90+ sprintf(ah, "%s", lin + matches[1].rm_so);
91+ }
92+ else {
93+ if ((ah = malloc (strlen(res->add_head) + strlen(lin + matches[1].rm_so) + 1)) == NULL)
94+ conf_err("AddHeader config: out of memory - aborted");
95+ sprintf(ah, "%s\r\n%s", res->add_head, lin + matches[1].rm_so);
96+ }
fd7feb9b
ER
97+ if (res->add_head)
98+ free(res->add_head);
1ec54a15
ER
99+ res->add_head = ah;
100 } else if(!regexec(&Ciphers, lin, 4, matches, 0)) {
101 lin[matches[1].rm_eo] = '\0';
102 SSL_CTX_set_cipher_list(res->ctx, lin + matches[1].rm_so);
fd7feb9b
ER
103--- ./pound.h.orig 2010-02-02 12:49:02.000000000 +0100
104+++ ./pound.h 2011-11-15 21:40:40.000000000 +0100
1ec54a15
ER
105@@ -354,7 +354,7 @@
106 SSL_CTX *ctx; /* CTX for SSL connections */
107 int clnt_check; /* client verification mode */
108 int noHTTPS11; /* HTTP 1.1 mode for SSL */
109- char *add_head; /* extra SSL header */
110+ char *add_head; /* extra headers */
111 regex_t verb; /* pattern to match the request verb against */
112 int to; /* client time-out */
113 int has_pat; /* was a URL pattern defined? */
fd7feb9b
ER
114--- ./pound.8.orig 2010-02-02 12:49:02.000000000 +0100
115+++ ./pound.8 2011-11-15 21:48:02.000000000 +0100
1ec54a15
ER
116@@ -405,7 +405,7 @@
117 .TP
118 \fBAddHeader\fR "header: to add"
119 Add the defined header to the request passed to the back-end server. The header
120-is added verbatim.
121+is added verbatim. Multiple headers can be added, one per AddHeader directive.
122 .TP
123 \fBRewriteLocation\fR 0|1|2
124 If 1 force
This page took 0.044962 seconds and 4 git commands to generate.