Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
h2_push.h
Go to the documentation of this file.
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements. See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __mod_h2__h2_push__
18 #define __mod_h2__h2_push__
19 
20 #include "h2.h"
21 
22 struct h2_request;
23 struct h2_headers;
24 struct h2_ngheader;
25 struct h2_session;
26 struct h2_stream;
27 
28 typedef struct h2_push {
29  const struct h2_request *req;
31 } h2_push;
32 
33 typedef enum {
37 
38 /*******************************************************************************
39  * push diary
40  *
41  * - The push diary keeps track of resources already PUSHed via HTTP/2 on this
42  * connection. It records a hash value from the absolute URL of the resource
43  * pushed.
44  * - Lacking openssl,
45  * - with openssl, it uses SHA256 to calculate the hash value, otherwise it
46  * falls back to apr_hashfunc_default()
47  * - whatever the method to generate the hash, the diary keeps a maximum of 64
48  * bits per hash, limiting the memory consumption to about
49  * H2PushDiarySize * 8
50  * bytes. Entries are sorted by most recently used and oldest entries are
51  * forgotten first.
52  * - While useful by itself to avoid duplicated PUSHes on the same connection,
53  * the original idea was that clients provided a 'Cache-Digest' header with
54  * the values of *their own* cached resources. This was described in
55  * <https://datatracker.ietf.org/doc/draft-kazuho-h2-cache-digest/>
56  * and some subsequent revisions that tweaked values but kept the overall idea.
57  * - The draft was abandoned by the IETF http-wg, as support from major clients,
58  * e.g. browsers, was lacking for various reasons.
59  * - For these reasons, mod_h2 abandoned its support for client supplied values
60  * but keeps the diary. It seems to provide value for applications using PUSH,
61  * is configurable in size and defaults to a very moderate amount of memory
62  * used.
63  * - The cache digest header is a Golomb Coded Set of hash values, but it may
64  * limit the amount of bits per hash value even further. For a good description
65  * of GCS, read here:
66  * <http://giovanni.bajo.it/post/47119962313/golomb-coded-sets-smaller-than-bloom-filters>
67  ******************************************************************************/
68 
69 
70 /*
71  * The push diary is based on the abandoned draft
72  * <https://datatracker.ietf.org/doc/draft-kazuho-h2-cache-digest/>
73  * that describes how to use golomb filters.
74  */
75 
77 
78 typedef void h2_push_digest_calc(h2_push_diary *diary, apr_uint64_t *phash, h2_push *push);
79 
80 struct h2_push_diary {
82  int NMax; /* Maximum for N, should size change be necessary */
83  int N; /* Current maximum number of entries, power of 2 */
84  apr_uint64_t mask; /* mask for relevant bits */
85  unsigned int mask_bits; /* number of relevant bits */
86  const char *authority;
89 };
90 
101  const struct h2_request *req,
102  apr_uint32_t push_policy,
103  const struct h2_headers *res);
104 
113 
119 
125  const struct h2_request *req,
126  const struct h2_headers *res);
139  int maxP, const char *authority,
140  const char **pdata, apr_size_t *plen);
141 
142 #endif /* defined(__mod_h2__h2_push__) */
size_t apr_size_t
Definition: apr.h:393
Definition: apr_tables.h:62
h2_push_diary * h2_push_diary_create(apr_pool_t *p, int N)
Definition: h2_push.h:35
Definition: h2.h:75
apr_array_header_t * h2_push_diary_update(struct h2_session *session, apr_array_header_t *pushes)
int NMax
Definition: h2_push.h:82
h2_push_digest_type dtype
Definition: h2_push.h:87
Definition: h2.h:133
Definition: h2_push.h:28
const struct h2_request * req
Definition: h2_push.h:29
apr_uint64_t mask
Definition: h2_push.h:84
const char * authority
Definition: h2_push.h:86
uint64_t apr_uint64_t
Definition: apr.h:386
apr_status_t h2_push_diary_digest_get(h2_push_diary *diary, apr_pool_t *p, int maxP, const char *authority, const char **pdata, apr_size_t *plen)
h2_priority * priority
Definition: h2_push.h:30
Definition: h2_stream.h:65
unsigned int apr_uint32_t
Definition: apr.h:347
h2_push_digest_type
Definition: h2_push.h:33
Definition: h2_push.h:80
apr_pool_t * p
Definition: h2_util.h:401
void h2_push_digest_calc(h2_push_diary *diary, apr_uint64_t *phash, h2_push *push)
Definition: h2_push.h:78
Definition: h2.h:159
apr_array_header_t * entries
Definition: h2_push.h:81
apr_array_header_t * h2_push_collect(apr_pool_t *p, const struct h2_request *req, apr_uint32_t push_policy, const struct h2_headers *res)
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
Definition: h2_push.h:34
apr_array_header_t * h2_push_collect_update(struct h2_stream *stream, const struct h2_request *req, const struct h2_headers *res)
int apr_status_t
Definition: apr_errno.h:44
h2_push_digest_calc * dcalc
Definition: h2_push.h:88
int N
Definition: h2_push.h:83
Definition: h2_session.h:76
struct h2_push h2_push
unsigned int mask_bits
Definition: h2_push.h:85