Mercurial > hg > nginx
annotate src/stream/ngx_stream_variables.h @ 7680:39501ce97e29
gRPC: generate error when response size is wrong.
As long as the "Content-Length" header is given, we now make sure
it exactly matches the size of the response. If it doesn't,
the response is considered malformed and must not be forwarded
(https://tools.ietf.org/html/rfc7540#section-8.1.2.6). While it
is not really possible to "not forward" the response which is already
being forwarded, we generate an error instead, which is the closest
equivalent.
Previous behaviour was to pass everything to the client, but this
seems to be suboptimal and causes issues (ticket #1695). Also this
directly contradicts HTTP/2 specification requirements.
Note that the new behaviour for the gRPC proxy is more strict than that
applied in other variants of proxying. This is intentional, as HTTP/2
specification requires us to do so, while in other types of proxying
malformed responses from backends are well known and historically
tolerated.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 06 Jul 2020 18:36:25 +0300 |
parents | 2a288909abc6 |
children |
rev | line source |
---|---|
6607 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 * Copyright (C) Nginx, Inc. | |
5 */ | |
6 | |
7 | |
8 #ifndef _NGX_STREAM_VARIABLES_H_INCLUDED_ | |
9 #define _NGX_STREAM_VARIABLES_H_INCLUDED_ | |
10 | |
11 | |
12 #include <ngx_config.h> | |
13 #include <ngx_core.h> | |
14 #include <ngx_stream.h> | |
15 | |
16 | |
17 typedef ngx_variable_value_t ngx_stream_variable_value_t; | |
18 | |
19 #define ngx_stream_variable(v) { sizeof(v) - 1, 1, 0, 0, 0, (u_char *) v } | |
20 | |
21 typedef struct ngx_stream_variable_s ngx_stream_variable_t; | |
22 | |
23 typedef void (*ngx_stream_set_variable_pt) (ngx_stream_session_t *s, | |
24 ngx_stream_variable_value_t *v, uintptr_t data); | |
25 typedef ngx_int_t (*ngx_stream_get_variable_pt) (ngx_stream_session_t *s, | |
26 ngx_stream_variable_value_t *v, uintptr_t data); | |
27 | |
28 | |
29 #define NGX_STREAM_VAR_CHANGEABLE 1 | |
30 #define NGX_STREAM_VAR_NOCACHEABLE 2 | |
31 #define NGX_STREAM_VAR_INDEXED 4 | |
32 #define NGX_STREAM_VAR_NOHASH 8 | |
6899
d2b2ff157da5
Variables: generic prefix variables.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6607
diff
changeset
|
33 #define NGX_STREAM_VAR_WEAK 16 |
d2b2ff157da5
Variables: generic prefix variables.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6607
diff
changeset
|
34 #define NGX_STREAM_VAR_PREFIX 32 |
6607 | 35 |
36 | |
37 struct ngx_stream_variable_s { | |
38 ngx_str_t name; /* must be first to build the hash */ | |
39 ngx_stream_set_variable_pt set_handler; | |
40 ngx_stream_get_variable_pt get_handler; | |
41 uintptr_t data; | |
42 ngx_uint_t flags; | |
43 ngx_uint_t index; | |
44 }; | |
45 | |
7077
2a288909abc6
Variables: macros for null variables.
Ruslan Ermilov <ru@nginx.com>
parents:
6899
diff
changeset
|
46 #define ngx_stream_null_variable { ngx_null_string, NULL, NULL, 0, 0, 0 } |
2a288909abc6
Variables: macros for null variables.
Ruslan Ermilov <ru@nginx.com>
parents:
6899
diff
changeset
|
47 |
6607 | 48 |
49 ngx_stream_variable_t *ngx_stream_add_variable(ngx_conf_t *cf, ngx_str_t *name, | |
50 ngx_uint_t flags); | |
51 ngx_int_t ngx_stream_get_variable_index(ngx_conf_t *cf, ngx_str_t *name); | |
52 ngx_stream_variable_value_t *ngx_stream_get_indexed_variable( | |
53 ngx_stream_session_t *s, ngx_uint_t index); | |
54 ngx_stream_variable_value_t *ngx_stream_get_flushed_variable( | |
55 ngx_stream_session_t *s, ngx_uint_t index); | |
56 | |
57 ngx_stream_variable_value_t *ngx_stream_get_variable(ngx_stream_session_t *s, | |
58 ngx_str_t *name, ngx_uint_t key); | |
59 | |
60 | |
61 #if (NGX_PCRE) | |
62 | |
63 typedef struct { | |
64 ngx_uint_t capture; | |
65 ngx_int_t index; | |
66 } ngx_stream_regex_variable_t; | |
67 | |
68 | |
69 typedef struct { | |
70 ngx_regex_t *regex; | |
71 ngx_uint_t ncaptures; | |
72 ngx_stream_regex_variable_t *variables; | |
73 ngx_uint_t nvariables; | |
74 ngx_str_t name; | |
75 } ngx_stream_regex_t; | |
76 | |
77 | |
78 typedef struct { | |
79 ngx_stream_regex_t *regex; | |
80 void *value; | |
81 } ngx_stream_map_regex_t; | |
82 | |
83 | |
84 ngx_stream_regex_t *ngx_stream_regex_compile(ngx_conf_t *cf, | |
85 ngx_regex_compile_t *rc); | |
86 ngx_int_t ngx_stream_regex_exec(ngx_stream_session_t *s, ngx_stream_regex_t *re, | |
87 ngx_str_t *str); | |
88 | |
89 #endif | |
90 | |
91 | |
92 typedef struct { | |
93 ngx_hash_combined_t hash; | |
94 #if (NGX_PCRE) | |
95 ngx_stream_map_regex_t *regex; | |
96 ngx_uint_t nregex; | |
97 #endif | |
98 } ngx_stream_map_t; | |
99 | |
100 | |
101 void *ngx_stream_map_find(ngx_stream_session_t *s, ngx_stream_map_t *map, | |
102 ngx_str_t *match); | |
103 | |
104 | |
105 ngx_int_t ngx_stream_variables_add_core_vars(ngx_conf_t *cf); | |
106 ngx_int_t ngx_stream_variables_init_vars(ngx_conf_t *cf); | |
107 | |
108 | |
109 extern ngx_stream_variable_value_t ngx_stream_variable_null_value; | |
110 extern ngx_stream_variable_value_t ngx_stream_variable_true_value; | |
111 | |
112 | |
113 #endif /* _NGX_STREAM_VARIABLES_H_INCLUDED_ */ |