#define COMP_FL_OFFLOAD 0x00000001 /* Compression offload */
#define COMP_FL_DIR_REQ 0x00000002 /* Compress requests */
#define COMP_FL_DIR_RES 0x00000004 /* Compress responses */
+#define COMP_FL_DIR_FORCED 0x00000008 /* Compress direction was forced */
struct comp {
struct comp_algo *algos_res; /* Algos available for response */
int ret = 0;
const char *res;
- /* always default to compress responses */
- comp = proxy_get_comp(proxy, COMP_FL_DIR_RES);
+ /* Algorithms enable their direction unless an explicit direction was set. */
+ comp = proxy_get_comp(proxy, 0);
if (comp == NULL) {
memprintf(err, "'%s': out of memory.", args[0]);
ret = -1;
cur_arg++;
continue;
}
+ if (!(comp->flags & COMP_FL_DIR_FORCED))
+ comp->flags |= COMP_FL_DIR_RES;
}
else if (strcmp(args[1], "algo-req") == 0) {
struct comp_ctx *ctx;
ret = -1;
goto end;
}
+ if (!(comp->flags & COMP_FL_DIR_FORCED))
+ comp->flags |= COMP_FL_DIR_REQ;
}
else if (strcmp(args[1], "offload") == 0) {
if (proxy->cap & PR_CAP_DEF) {
}
if (strcmp(args[2], "request") == 0) {
comp->flags &= ~COMP_FL_DIR_RES;
- comp->flags |= COMP_FL_DIR_REQ;
+ comp->flags |= (COMP_FL_DIR_FORCED | COMP_FL_DIR_REQ);
} else if (strcmp(args[2], "response") == 0) {
comp->flags &= ~COMP_FL_DIR_REQ;
- comp->flags |= COMP_FL_DIR_RES;
+ comp->flags |= (COMP_FL_DIR_FORCED | COMP_FL_DIR_RES);
} else if (strcmp(args[2], "both") == 0)
- comp->flags |= COMP_FL_DIR_REQ | COMP_FL_DIR_RES;
+ comp->flags |= (COMP_FL_DIR_FORCED | COMP_FL_DIR_REQ | COMP_FL_DIR_RES);
else {
memprintf(err, "'%s' expects 'request', 'response', or 'both'.", args[0]);
ret = -1;