Project

General

Profile

mod_setenv.c.patch

georgexsh, 2009-06-21 06:37

View differences:

../lighttpd-1.4.22/src/mod_setenv.c 2009-02-19 21:15:14.000000000 +0800
20 20
	array *response_header;
21 21

  
22 22
	array *environment;
23

  
24
	array *request_header_set;
25 23
} plugin_config;
26 24

  
27 25
typedef struct {
......
72 70
			array_free(s->request_header);
73 71
			array_free(s->response_header);
74 72
			array_free(s->environment);
75
			array_free(s->request_header_set);
76 73

  
77 74
			free(s);
78 75
		}
......
94 91
		{ "setenv.add-request-header",  NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION },       /* 0 */
95 92
		{ "setenv.add-response-header", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION },       /* 1 */
96 93
		{ "setenv.add-environment",     NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION },       /* 2 */
97
		{ "setenv.set-request-header",  NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION },       /* 3 */
98 94
		{ NULL,                         NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
99 95
	};
100 96

  
......
106 102
		plugin_config *s;
107 103

  
108 104
		s = calloc(1, sizeof(plugin_config));
109
		s->request_header       = array_init();
110
		s->response_header      = array_init();
111
		s->environment          = array_init();
112
		s->request_header_set   = array_init();
105
		s->request_header   = array_init();
106
		s->response_header  = array_init();
107
		s->environment      = array_init();
113 108

  
114 109
		cv[0].destination = s->request_header;
115 110
		cv[1].destination = s->response_header;
116 111
		cv[2].destination = s->environment;
117
		cv[3].destination = s->request_header_set;
118 112

  
119 113
		p->config_storage[i] = s;
120 114

  
......
135 129
	PATCH(request_header);
136 130
	PATCH(response_header);
137 131
	PATCH(environment);
138
	PATCH(request_header_set);
139 132

  
140 133
	/* skip the first, the global context */
141 134
	for (i = 1; i < srv->config_context->used; i++) {
......
155 148
				PATCH(response_header);
156 149
			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("setenv.add-environment"))) {
157 150
				PATCH(environment);
158
			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("setenv.set-request-header"))) {
159
				PATCH(request_header_set);
160
            }
151
			}
161 152
		}
162 153
	}
163 154

  
......
220 211
		response_header_insert(srv, con, CONST_BUF_LEN(ds->key), CONST_BUF_LEN(ds->value));
221 212
	}
222 213

  
223
	for (k = 0; k < p->conf.request_header_set->used; k++) {
224
		data_string *ds = (data_string *)p->conf.request_header_set->data[k];
225
		data_string *ds_dst;
226

  
227
		if (NULL != (ds_dst = (data_string *)array_get_element(con->request.headers, ds->key->ptr))) {
228
            // mod the header
229
            buffer_copy_string_buffer(ds_dst->value, ds->value);
230
            continue;
231
		}
232

  
233
        // insert a header
234

  
235
        ds_dst = data_string_init();
236
		buffer_copy_string_buffer(ds_dst->key, ds->key);
237
		buffer_copy_string_buffer(ds_dst->value, ds->value);
238

  
239
		array_insert_unique(con->request.headers, (data_unset *)ds_dst);
240
	}
241

  
242 214
	/* not found */
243 215
	return HANDLER_GO_ON;
244 216
}
......
273 245

  
274 246
	return 0;
275 247
}
276