[go: nahoru, domu]

Skip to content

Commit

Permalink
split proxy_should_drop flag into for-request and for-response flags
Browse files Browse the repository at this point in the history
  • Loading branch information
i110 committed Sep 4, 2017
1 parent 8f604db commit 9711289
Show file tree
Hide file tree
Showing 8 changed files with 212 additions and 142 deletions.
3 changes: 2 additions & 1 deletion include/h2o.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ typedef struct st_h2o_headers_command_t h2o_headers_command_t;
typedef struct st_h2o_token_t {
h2o_iovec_t buf;
char http2_static_table_name_index; /* non-zero if any */
unsigned char proxy_should_drop : 1;
unsigned char proxy_should_drop_for_req : 1;
unsigned char proxy_should_drop_for_res : 1;
unsigned char is_init_header_special : 1;
unsigned char http2_should_reject : 1;
unsigned char copy_for_push_request : 1;
Expand Down
4 changes: 2 additions & 2 deletions lib/core/proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ static h2o_iovec_t build_request_rest_headers(h2o_req_t *req, int keepalive, int
for (h = req_headers.entries, h_end = h + req_headers.size; h != h_end; ++h) {
if (h2o_iovec_is_token(h->name)) {
const h2o_token_t *token = (void *)h->name;
if (token->proxy_should_drop) {
if (token->proxy_should_drop_for_req) {
continue;
} else if (token == H2O_TOKEN_COOKIE) {
/* merge the cookie headers; see HTTP/2 8.1.2.5 and HTTP/1 (RFC6265 5.4) */
Expand Down Expand Up @@ -471,7 +471,7 @@ static h2o_http1client_body_cb on_head(h2o_http1client_t *client, const char *er
if (h2o_iovec_is_token(headers[i].name)) {
const h2o_token_t *token = H2O_STRUCT_FROM_MEMBER(h2o_token_t, buf, headers[i].name);
h2o_iovec_t value;
if (token->proxy_should_drop) {
if (token->proxy_should_drop_for_res) {
goto Skip;
}
if (token == H2O_TOKEN_CONTENT_LENGTH) {
Expand Down
124 changes: 62 additions & 62 deletions lib/core/token_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,68 +21,68 @@
*/

/* DO NOT EDIT! generated by tokens.pl */
h2o_token_t h2o__tokens[] = {{{H2O_STRLIT(":authority")}, 1, 0, 0, 0, 0},
{{H2O_STRLIT(":method")}, 2, 0, 0, 0, 0},
{{H2O_STRLIT(":path")}, 4, 0, 0, 0, 0},
{{H2O_STRLIT(":scheme")}, 6, 0, 0, 0, 0},
{{H2O_STRLIT(":status")}, 8, 0, 0, 0, 0},
{{H2O_STRLIT("accept")}, 19, 0, 0, 0, 1},
{{H2O_STRLIT("accept-charset")}, 15, 0, 0, 0, 1},
{{H2O_STRLIT("accept-encoding")}, 16, 0, 0, 0, 1},
{{H2O_STRLIT("accept-language")}, 17, 0, 0, 0, 1},
{{H2O_STRLIT("accept-ranges")}, 18, 0, 0, 0, 0},
{{H2O_STRLIT("access-control-allow-origin")}, 20, 0, 0, 0, 0},
{{H2O_STRLIT("age")}, 21, 0, 0, 0, 0},
{{H2O_STRLIT("allow")}, 22, 0, 0, 0, 0},
{{H2O_STRLIT("authorization")}, 23, 0, 0, 0, 0},
{{H2O_STRLIT("cache-control")}, 24, 0, 0, 0, 0},
{{H2O_STRLIT("cache-digest")}, 0, 0, 0, 0, 0},
{{H2O_STRLIT("connection")}, 0, 1, 0, 1, 0},
{{H2O_STRLIT("content-disposition")}, 25, 0, 0, 0, 0},
{{H2O_STRLIT("content-encoding")}, 26, 0, 0, 0, 0},
{{H2O_STRLIT("content-language")}, 27, 0, 0, 0, 0},
{{H2O_STRLIT("content-length")}, 28, 0, 1, 0, 0},
{{H2O_STRLIT("content-location")}, 29, 0, 0, 0, 0},
{{H2O_STRLIT("content-range")}, 30, 0, 0, 0, 0},
{{H2O_STRLIT("content-type")}, 31, 0, 0, 0, 0},
{{H2O_STRLIT("cookie")}, 32, 0, 0, 0, 0},
{{H2O_STRLIT("date")}, 33, 1, 0, 0, 0},
{{H2O_STRLIT("etag")}, 34, 0, 0, 0, 0},
{{H2O_STRLIT("expect")}, 35, 0, 1, 0, 0},
{{H2O_STRLIT("expires")}, 36, 0, 0, 0, 0},
{{H2O_STRLIT("from")}, 37, 0, 0, 0, 0},
{{H2O_STRLIT("host")}, 38, 0, 1, 1, 0},
{{H2O_STRLIT("http2-settings")}, 0, 1, 0, 1, 0},
{{H2O_STRLIT("if-match")}, 39, 0, 0, 0, 0},
{{H2O_STRLIT("if-modified-since")}, 40, 0, 0, 0, 0},
{{H2O_STRLIT("if-none-match")}, 41, 0, 0, 0, 0},
{{H2O_STRLIT("if-range")}, 42, 0, 0, 0, 0},
{{H2O_STRLIT("if-unmodified-since")}, 43, 0, 0, 0, 0},
{{H2O_STRLIT("keep-alive")}, 0, 1, 0, 0, 0},
{{H2O_STRLIT("last-modified")}, 44, 0, 0, 0, 0},
{{H2O_STRLIT("link")}, 45, 0, 0, 0, 0},
{{H2O_STRLIT("location")}, 46, 0, 0, 0, 0},
{{H2O_STRLIT("max-forwards")}, 47, 0, 0, 0, 0},
{{H2O_STRLIT("proxy-authenticate")}, 48, 1, 0, 0, 0},
{{H2O_STRLIT("proxy-authorization")}, 49, 1, 0, 0, 0},
{{H2O_STRLIT("range")}, 50, 0, 0, 0, 0},
{{H2O_STRLIT("referer")}, 51, 0, 0, 0, 0},
{{H2O_STRLIT("refresh")}, 52, 0, 0, 0, 0},
{{H2O_STRLIT("retry-after")}, 53, 0, 0, 0, 0},
{{H2O_STRLIT("server")}, 54, 0, 0, 0, 0},
{{H2O_STRLIT("set-cookie")}, 55, 0, 0, 0, 0},
{{H2O_STRLIT("strict-transport-security")}, 56, 0, 0, 0, 0},
{{H2O_STRLIT("te")}, 0, 1, 0, 1, 0},
{{H2O_STRLIT("transfer-encoding")}, 57, 1, 1, 1, 0},
{{H2O_STRLIT("upgrade")}, 0, 1, 1, 1, 0},
{{H2O_STRLIT("user-agent")}, 58, 0, 0, 0, 1},
{{H2O_STRLIT("vary")}, 59, 0, 0, 0, 0},
{{H2O_STRLIT("via")}, 60, 0, 0, 0, 0},
{{H2O_STRLIT("www-authenticate")}, 61, 0, 0, 0, 0},
{{H2O_STRLIT("x-compress-hint")}, 0, 0, 0, 0, 0},
{{H2O_STRLIT("x-forwarded-for")}, 0, 0, 0, 0, 0},
{{H2O_STRLIT("x-reproxy-url")}, 0, 0, 0, 0, 0},
{{H2O_STRLIT("x-traffic")}, 0, 0, 0, 0, 0}};
h2o_token_t h2o__tokens[] = {{{H2O_STRLIT(":authority")}, 1, 0, 0, 0, 0, 0},
{{H2O_STRLIT(":method")}, 2, 0, 0, 0, 0, 0},
{{H2O_STRLIT(":path")}, 4, 0, 0, 0, 0, 0},
{{H2O_STRLIT(":scheme")}, 6, 0, 0, 0, 0, 0},
{{H2O_STRLIT(":status")}, 8, 0, 0, 0, 0, 0},
{{H2O_STRLIT("accept")}, 19, 0, 0, 0, 0, 1},
{{H2O_STRLIT("accept-charset")}, 15, 0, 0, 0, 0, 1},
{{H2O_STRLIT("accept-encoding")}, 16, 0, 0, 0, 0, 1},
{{H2O_STRLIT("accept-language")}, 17, 0, 0, 0, 0, 1},
{{H2O_STRLIT("accept-ranges")}, 18, 0, 0, 0, 0, 0},
{{H2O_STRLIT("access-control-allow-origin")}, 20, 0, 0, 0, 0, 0},
{{H2O_STRLIT("age")}, 21, 0, 0, 0, 0, 0},
{{H2O_STRLIT("allow")}, 22, 0, 0, 0, 0, 0},
{{H2O_STRLIT("authorization")}, 23, 0, 0, 0, 0, 0},
{{H2O_STRLIT("cache-control")}, 24, 0, 0, 0, 0, 0},
{{H2O_STRLIT("cache-digest")}, 0, 0, 0, 0, 0, 0},
{{H2O_STRLIT("connection")}, 0, 1, 1, 0, 1, 0},
{{H2O_STRLIT("content-disposition")}, 25, 0, 0, 0, 0, 0},
{{H2O_STRLIT("content-encoding")}, 26, 0, 0, 0, 0, 0},
{{H2O_STRLIT("content-language")}, 27, 0, 0, 0, 0, 0},
{{H2O_STRLIT("content-length")}, 28, 0, 0, 1, 0, 0},
{{H2O_STRLIT("content-location")}, 29, 0, 0, 0, 0, 0},
{{H2O_STRLIT("content-range")}, 30, 0, 0, 0, 0, 0},
{{H2O_STRLIT("content-type")}, 31, 0, 0, 0, 0, 0},
{{H2O_STRLIT("cookie")}, 32, 0, 0, 0, 0, 0},
{{H2O_STRLIT("date")}, 33, 0, 1, 0, 0, 0},
{{H2O_STRLIT("etag")}, 34, 0, 0, 0, 0, 0},
{{H2O_STRLIT("expect")}, 35, 0, 0, 1, 0, 0},
{{H2O_STRLIT("expires")}, 36, 0, 0, 0, 0, 0},
{{H2O_STRLIT("from")}, 37, 0, 0, 0, 0, 0},
{{H2O_STRLIT("host")}, 38, 0, 0, 1, 1, 0},
{{H2O_STRLIT("http2-settings")}, 0, 1, 0, 0, 1, 0},
{{H2O_STRLIT("if-match")}, 39, 0, 0, 0, 0, 0},
{{H2O_STRLIT("if-modified-since")}, 40, 0, 0, 0, 0, 0},
{{H2O_STRLIT("if-none-match")}, 41, 0, 0, 0, 0, 0},
{{H2O_STRLIT("if-range")}, 42, 0, 0, 0, 0, 0},
{{H2O_STRLIT("if-unmodified-since")}, 43, 0, 0, 0, 0, 0},
{{H2O_STRLIT("keep-alive")}, 0, 1, 1, 0, 0, 0},
{{H2O_STRLIT("last-modified")}, 44, 0, 0, 0, 0, 0},
{{H2O_STRLIT("link")}, 45, 0, 0, 0, 0, 0},
{{H2O_STRLIT("location")}, 46, 0, 0, 0, 0, 0},
{{H2O_STRLIT("max-forwards")}, 47, 0, 0, 0, 0, 0},
{{H2O_STRLIT("proxy-authenticate")}, 48, 1, 0, 0, 0, 0},
{{H2O_STRLIT("proxy-authorization")}, 49, 1, 0, 0, 0, 0},
{{H2O_STRLIT("range")}, 50, 0, 0, 0, 0, 0},
{{H2O_STRLIT("referer")}, 51, 0, 0, 0, 0, 0},
{{H2O_STRLIT("refresh")}, 52, 0, 0, 0, 0, 0},
{{H2O_STRLIT("retry-after")}, 53, 0, 0, 0, 0, 0},
{{H2O_STRLIT("server")}, 54, 0, 0, 0, 0, 0},
{{H2O_STRLIT("set-cookie")}, 55, 0, 0, 0, 0, 0},
{{H2O_STRLIT("strict-transport-security")}, 56, 0, 0, 0, 0, 0},
{{H2O_STRLIT("te")}, 0, 1, 0, 0, 1, 0},
{{H2O_STRLIT("transfer-encoding")}, 57, 1, 1, 1, 1, 0},
{{H2O_STRLIT("upgrade")}, 0, 1, 0, 1, 1, 0},
{{H2O_STRLIT("user-agent")}, 58, 0, 0, 0, 0, 1},
{{H2O_STRLIT("vary")}, 59, 0, 0, 0, 0, 0},
{{H2O_STRLIT("via")}, 60, 0, 0, 0, 0, 0},
{{H2O_STRLIT("www-authenticate")}, 61, 0, 0, 0, 0, 0},
{{H2O_STRLIT("x-compress-hint")}, 0, 0, 0, 0, 0, 0},
{{H2O_STRLIT("x-forwarded-for")}, 0, 0, 0, 0, 0, 0},
{{H2O_STRLIT("x-reproxy-url")}, 0, 0, 0, 0, 0, 0},
{{H2O_STRLIT("x-traffic")}, 0, 0, 0, 0, 0, 0}};
size_t h2o__num_tokens = 62;

const h2o_token_t *h2o_lookup_token(const char *name, size_t len)
Expand Down
2 changes: 1 addition & 1 deletion lib/handler/fastcgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ static int fill_headers(h2o_req_t *req, struct phr_header *headers, size_t num_h
const h2o_token_t *token;
h2o_strtolower((char *)headers[i].name, headers[i].name_len);
if ((token = h2o_lookup_token(headers[i].name, headers[i].name_len)) != NULL) {
if (token->proxy_should_drop) {
if (token->proxy_should_drop_for_res) {
/* skip */
} else if (token == H2O_TOKEN_CONTENT_LENGTH) {
if (req->res.content_length != SIZE_MAX) {
Expand Down
2 changes: 1 addition & 1 deletion lib/handler/mruby.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ static int handle_response_header(h2o_mruby_shared_context_t *shared_ctx, h2o_io
h2o_strtolower(name.base, name.len);

if ((token = h2o_lookup_token(name.base, name.len)) != NULL) {
if (token->proxy_should_drop) {
if (token->proxy_should_drop_for_res) {
/* skip */
} else if (token == H2O_TOKEN_CONTENT_LENGTH) {
req->res.content_length = h2o_strtosize(value.base, value.len);
Expand Down
151 changes: 76 additions & 75 deletions misc/tokens.pl
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@

while (my $line = <DATA>) {
chomp $line;
my ($hpack_index, $proxy_should_drop, $is_init_header_special, $http2_should_reject, $copy_for_push_request, $name, $value) =
split /\s+/, $line, 7;
my ($hpack_index, $proxy_should_drop_for_req, $proxy_should_drop_for_res, $is_init_header_special, $http2_should_reject, $copy_for_push_request, $name, $value) =
split /\s+/, $line, 8;
next unless $name ne '';
$tokens{$name} = [ $hpack_index, $proxy_should_drop, $is_init_header_special, $http2_should_reject, $copy_for_push_request ]
$tokens{$name} = [ $hpack_index, $proxy_should_drop_for_req, $proxy_should_drop_for_res, $is_init_header_special, $http2_should_reject, $copy_for_push_request ]
unless defined $tokens{$name};
if ($hpack_index != 0) {
$hpack[$hpack_index - 1] = [ $name, $value ];
Expand Down Expand Up @@ -153,80 +153,81 @@ sub normalize_name {
#
# Meaning of the fields:
# - HTTP/2 static table index (non-zero if present)
# - Proxy should drop
# - Proxy should drop in request
# - Proxy should drop in response
# - Is init header special
# - HTTP/2 should reject
# - Copy for push request

__DATA__
1 0 0 0 0 :authority
2 0 0 0 0 :method GET
3 0 0 0 0 :method POST
4 0 0 0 0 :path /
5 0 0 0 0 :path /index.html
6 0 0 0 0 :scheme http
7 0 0 0 0 :scheme https
8 0 0 0 0 :status 200
9 0 0 0 0 :status 204
10 0 0 0 0 :status 206
11 0 0 0 0 :status 304
12 0 0 0 0 :status 400
13 0 0 0 0 :status 404
14 0 0 0 0 :status 500
15 0 0 0 1 accept-charset
16 0 0 0 1 accept-encoding gzip, deflate
17 0 0 0 1 accept-language
18 0 0 0 0 accept-ranges
19 0 0 0 1 accept
20 0 0 0 0 access-control-allow-origin
21 0 0 0 0 age
22 0 0 0 0 allow
23 0 0 0 0 authorization
24 0 0 0 0 cache-control
25 0 0 0 0 content-disposition
26 0 0 0 0 content-encoding
27 0 0 0 0 content-language
28 0 1 0 0 content-length
29 0 0 0 0 content-location
30 0 0 0 0 content-range
31 0 0 0 0 content-type
32 0 0 0 0 cookie
33 1 0 0 0 date
34 0 0 0 0 etag
35 0 1 0 0 expect
36 0 0 0 0 expires
37 0 0 0 0 from
38 0 1 1 0 host
39 0 0 0 0 if-match
40 0 0 0 0 if-modified-since
41 0 0 0 0 if-none-match
42 0 0 0 0 if-range
43 0 0 0 0 if-unmodified-since
44 0 0 0 0 last-modified
45 0 0 0 0 link
46 0 0 0 0 location
47 0 0 0 0 max-forwards
48 1 0 0 0 proxy-authenticate
49 1 0 0 0 proxy-authorization
50 0 0 0 0 range
51 0 0 0 0 referer
52 0 0 0 0 refresh
53 0 0 0 0 retry-after
54 0 0 0 0 server
55 0 0 0 0 set-cookie
56 0 0 0 0 strict-transport-security
57 1 1 1 0 transfer-encoding
58 0 0 0 1 user-agent
59 0 0 0 0 vary
60 0 0 0 0 via
61 0 0 0 0 www-authenticate
0 1 0 1 0 connection
0 0 0 0 0 x-reproxy-url
0 1 1 1 0 upgrade
0 1 0 1 0 http2-settings
0 1 0 1 0 te
0 1 0 0 0 keep-alive
0 0 0 0 0 x-forwarded-for
0 0 0 0 0 x-traffic
0 0 0 0 0 cache-digest
0 0 0 0 0 x-compress-hint
1 0 0 0 0 0 :authority
2 0 0 0 0 0 :method GET
3 0 0 0 0 0 :method POST
4 0 0 0 0 0 :path /
5 0 0 0 0 0 :path /index.html
6 0 0 0 0 0 :scheme http
7 0 0 0 0 0 :scheme https
8 0 0 0 0 0 :status 200
9 0 0 0 0 0 :status 204
10 0 0 0 0 0 :status 206
11 0 0 0 0 0 :status 304
12 0 0 0 0 0 :status 400
13 0 0 0 0 0 :status 404
14 0 0 0 0 0 :status 500
15 0 0 0 0 1 accept-charset
16 0 0 0 0 1 accept-encoding gzip, deflate
17 0 0 0 0 1 accept-language
18 0 0 0 0 0 accept-ranges
19 0 0 0 0 1 accept
20 0 0 0 0 0 access-control-allow-origin
21 0 0 0 0 0 age
22 0 0 0 0 0 allow
23 0 0 0 0 0 authorization
24 0 0 0 0 0 cache-control
25 0 0 0 0 0 content-disposition
26 0 0 0 0 0 content-encoding
27 0 0 0 0 0 content-language
28 0 0 1 0 0 content-length
29 0 0 0 0 0 content-location
30 0 0 0 0 0 content-range
31 0 0 0 0 0 content-type
32 0 0 0 0 0 cookie
33 0 1 0 0 0 date
34 0 0 0 0 0 etag
35 0 0 1 0 0 expect
36 0 0 0 0 0 expires
37 0 0 0 0 0 from
38 0 0 1 1 0 host
39 0 0 0 0 0 if-match
40 0 0 0 0 0 if-modified-since
41 0 0 0 0 0 if-none-match
42 0 0 0 0 0 if-range
43 0 0 0 0 0 if-unmodified-since
44 0 0 0 0 0 last-modified
45 0 0 0 0 0 link
46 0 0 0 0 0 location
47 0 0 0 0 0 max-forwards
48 1 0 0 0 0 proxy-authenticate
49 1 0 0 0 0 proxy-authorization
50 0 0 0 0 0 range
51 0 0 0 0 0 referer
52 0 0 0 0 0 refresh
53 0 0 0 0 0 retry-after
54 0 0 0 0 0 server
55 0 0 0 0 0 set-cookie
56 0 0 0 0 0 strict-transport-security
57 1 1 1 1 0 transfer-encoding
58 0 0 0 0 1 user-agent
59 0 0 0 0 0 vary
60 0 0 0 0 0 via
61 0 0 0 0 0 www-authenticate
0 1 1 0 1 0 connection
0 0 0 0 0 0 x-reproxy-url
0 1 0 1 1 0 upgrade
0 1 0 0 1 0 http2-settings
0 1 0 0 1 0 te
0 1 1 0 0 0 keep-alive
0 0 0 0 0 0 x-forwarded-for
0 0 0 0 0 0 x-traffic
0 0 0 0 0 0 cache-digest
0 0 0 0 0 0 x-compress-hint
Loading

0 comments on commit 9711289

Please sign in to comment.