* Add a content-type in the configuration
* Returns 0 in case of success, 1 in case of allocation failure.
*/
-int comp_append_type(struct comp *comp, const char *type)
+int comp_append_type(struct comp_type **types, const char *type)
{
struct comp_type *comp_type;
return 1;
comp_type->name_len = strlen(type);
comp_type->name = strdup(type);
- comp_type->next = comp->types;
- comp->types = comp_type;
+ comp_type->next = *types;
+ *types = comp_type;
return 0;
}
* Returns 0 in case of success, -1 if the <algo> is unmanaged, 1 in case of
* allocation failure.
*/
-int comp_append_algo(struct comp *comp, const char *algo)
+int comp_append_algo(struct comp_algo **algos, const char *algo)
{
struct comp_algo *comp_algo;
int i;
if (!comp_algo)
return 1;
memmove(comp_algo, &comp_algos[i], sizeof(struct comp_algo));
- comp_algo->next = comp->algos;
- comp->algos = comp_algo;
+ comp_algo->next = *algos;
+ *algos = comp_algo;
return 0;
}
}
}
/* search for the algo in the backend in priority or the frontend */
- if ((s->be->comp && (comp_algo_back = s->be->comp->algos)) ||
- (strm_fe(s)->comp && (comp_algo_back = strm_fe(s)->comp->algos))) {
+ if ((s->be->comp && (comp_algo_back = s->be->comp->algos_res)) ||
+ (strm_fe(s)->comp && (comp_algo_back = strm_fe(s)->comp->algos_res))) {
int best_q = 0;
ctx.blk = NULL;
}
/* identity is implicit does not require headers */
- if ((s->be->comp && (comp_algo_back = s->be->comp->algos)) ||
- (strm_fe(s)->comp && (comp_algo_back = strm_fe(s)->comp->algos))) {
+ if ((s->be->comp && (comp_algo_back = s->be->comp->algos_res)) ||
+ (strm_fe(s)->comp && (comp_algo_back = strm_fe(s)->comp->algos_res))) {
for (comp_algo = comp_algo_back; comp_algo; comp_algo = comp_algo->next) {
if (comp_algo->cfg_name_len == 8 && memcmp(comp_algo->cfg_name, "identity", 8) == 0) {
st->comp_algo[COMP_DIR_RES] = comp_algo;
if (ctx.value.len >= 9 && strncasecmp("multipart", ctx.value.ptr, 9) == 0)
goto fail;
- if ((s->be->comp && (comp_type = s->be->comp->types)) ||
- (strm_fe(s)->comp && (comp_type = strm_fe(s)->comp->types))) {
+ if ((s->be->comp && (comp_type = s->be->comp->types_res)) ||
+ (strm_fe(s)->comp && (comp_type = strm_fe(s)->comp->types_res))) {
for (; comp_type; comp_type = comp_type->next) {
if (ctx.value.len >= comp_type->name_len &&
strncasecmp(ctx.value.ptr, comp_type->name, comp_type->name_len) == 0)
}
}
else { /* no content-type header */
- if ((s->be->comp && s->be->comp->types) ||
- (strm_fe(s)->comp && strm_fe(s)->comp->types))
+ if ((s->be->comp && s->be->comp->types_res) ||
+ (strm_fe(s)->comp && strm_fe(s)->comp->types_res))
goto fail; /* a content-type was required */
}
else
comp = proxy->comp;
- if (strcmp(args[1], "algo") == 0) {
+ if (strcmp(args[1], "algo") == 0 || strcmp(args[1], "algo-res") == 0) {
struct comp_ctx *ctx;
int cur_arg = 2;
goto end;
}
while (*(args[cur_arg])) {
- int retval = comp_append_algo(comp, args[cur_arg]);
+ int retval = comp_append_algo(&comp->algos_res, args[cur_arg]);
if (retval) {
if (retval < 0)
memprintf(err, "'%s' : '%s' is not a supported algorithm.",
goto end;
}
- if (proxy->comp->algos->init(&ctx, 9) == 0)
- proxy->comp->algos->end(&ctx);
+ if (proxy->comp->algos_res->init(&ctx, 9) == 0)
+ proxy->comp->algos_res->end(&ctx);
else {
memprintf(err, "'%s' : Can't init '%s' algorithm.",
args[0], args[cur_arg]);
}
comp->flags |= COMP_FL_OFFLOAD;
}
- else if (strcmp(args[1], "type") == 0) {
+ else if (strcmp(args[1], "type") == 0 || strcmp(args[1], "type-res") == 0) {
int cur_arg = 2;
if (!*args[cur_arg]) {
goto end;
}
while (*(args[cur_arg])) {
- if (comp_append_type(comp, args[cur_arg])) {
+ if (comp_append_type(&comp->types_res, args[cur_arg])) {
memprintf(err, "'%s': out of memory.", args[0]);
ret = -1;
goto end;