summaryrefslogtreecommitdiffstats
path: root/include/haproxy/fcgi-app-t.h
blob: fb6ab27405dbb1cccd2404cd6a62757c03d145fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
 * include/haproxy/fcgi-app-t.h
 * This file defines everything related to FCGI applications.
 *
 * Copyright (C) 2019 HAProxy Technologies, Christopher Faulet <cfaulet@haproxy.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation, version 2.1
 * exclusively.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef _HAPROXY_HTTP_FCGI_T_H
#define _HAPROXY_HTTP_FCGI_T_H

#include <import/ebtree-t.h>
#include <import/ist.h>

#include <haproxy/acl-t.h>
#include <haproxy/api-t.h>
#include <haproxy/arg-t.h>
#include <haproxy/fcgi.h>
#include <haproxy/filters-t.h>
#include <haproxy/regex-t.h>

#define FCGI_APP_FL_KEEP_CONN     0x00000001 /* Keep the connection alive */
#define FCGI_APP_FL_GET_VALUES    0x00000002 /* Retrieve FCGI variables on connection establishment */
#define FCGI_APP_FL_MPXS_CONNS    0x00000004 /* FCGI APP supports connection multiplexing */


enum fcgi_rule_type {
	FCGI_RULE_SET_PARAM = 0,
	FCGI_RULE_UNSET_PARAM,
	FCGI_RULE_PASS_HDR,
	FCGI_RULE_HIDE_HDR,
};

/* Used during configuration parsing only and converted into fcgi_rule when
 * filter is created.
 */
struct fcgi_rule_conf {
	enum fcgi_rule_type type;
	char *name;
	char *value;
	struct acl_cond *cond; /* acl condition to set/unset the param */
	struct list list;
};

/* parameter rule evaluated during request analyzis */
struct fcgi_rule {
	enum fcgi_rule_type type;
	struct ist name;       /* name of the parameter/header */
	struct list value;     /* log-format compatible expression, may be empty */
	struct acl_cond *cond; /* acl condition to set the param */
	struct list list;
};

/* parameter rule to set/unset a param at the end of the analyzis */
struct fcgi_param_rule {
	struct ist name;
	struct list *value; /* if empty , unset the parameter */
	struct ebpt_node node;
};

/* header rule to pass/hide a header at the end of the analyzis */
struct fcgi_hdr_rule {
	struct ist name;
	int pass; /* 1 to pass the header, 0 Otherwise */
	struct ebpt_node node;
};

struct fcgi_app {
	char              *name;          /* name to identify this set of params */
	struct ist         docroot;       /* FCGI docroot */
	struct ist         index;         /* filename to append to URI ending by a '/' */
	struct my_regex   *pathinfo_re;   /* Regex to use to split scriptname and path-info */
	unsigned int       flags;         /* FCGI_APP_FL_* */
	struct list        loggers;       /* one per 'log' directive */
	unsigned int       maxreqs;       /* maximum number of concurrent requests */

	struct list acls;                 /* list of acls declared for this application */

	struct {
		char *file;               /* file where the section appears */
		int   line;               /* line where the section appears */
		struct list rules;        /* list of rules used during config parsing */
		struct arg_list args;     /* sample arg list that need to be resolved */
	} conf;                           /* config information */
	struct fcgi_app *next;            /* used to chain fcgi-app */
};

/* FCGI config attached to backend proxies */
struct fcgi_flt_conf {
	char *name;                  /* fcgi-app name used during config parsing */
	struct fcgi_app *app;        /* configuration of the fcgi application */

	struct list param_rules;     /* list of set/unset rules */
	struct list hdr_rules;       /* list of pass/add rules  */
};

/* FCGI context attached to streames */
struct fcgi_flt_ctx {
	struct filter *filter;
	struct fcgi_app *app;
};

#endif /* _HAPROXY_HTTP_FCGI_T_H */

/*
 * Local variables:
 *  c-indent-level: 8
 *  c-basic-offset: 8
 * End:
 */