Apache HTTPD
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 <http_protocol.h>
21
22#include "h2.h"
23#include "h2_headers.h"
24
25struct h2_request;
26struct h2_ngheader;
27struct h2_session;
28struct h2_stream;
29
30typedef struct h2_push {
31 const struct h2_request *req;
34
39
40/*******************************************************************************
41 * push diary
42 *
43 * - The push diary keeps track of resources already PUSHed via HTTP/2 on this
44 * connection. It records a hash value from the absolute URL of the resource
45 * pushed.
46 * - Lacking openssl,
47 * - with openssl, it uses SHA256 to calculate the hash value, otherwise it
48 * falls back to apr_hashfunc_default()
49 * - whatever the method to generate the hash, the diary keeps a maximum of 64
50 * bits per hash, limiting the memory consumption to about
51 * H2PushDiarySize * 8
52 * bytes. Entries are sorted by most recently used and oldest entries are
53 * forgotten first.
54 * - While useful by itself to avoid duplicated PUSHes on the same connection,
55 * the original idea was that clients provided a 'Cache-Digest' header with
56 * the values of *their own* cached resources. This was described in
57 * <https://datatracker.ietf.org/doc/draft-kazuho-h2-cache-digest/>
58 * and some subsequent revisions that tweaked values but kept the overall idea.
59 * - The draft was abandoned by the IETF http-wg, as support from major clients,
60 * e.g. browsers, was lacking for various reasons.
61 * - For these reasons, mod_h2 abandoned its support for client supplied values
62 * but keeps the diary. It seems to provide value for applications using PUSH,
63 * is configurable in size and defaults to a very moderate amount of memory
64 * used.
65 * - The cache digest header is a Golomb Coded Set of hash values, but it may
66 * limit the amount of bits per hash value even further. For a good description
67 * of GCS, read here:
68 * <http://giovanni.bajo.it/post/47119962313/golomb-coded-sets-smaller-than-bloom-filters>
69 ******************************************************************************/
70
71
72/*
73 * The push diary is based on the abandoned draft
74 * <https://datatracker.ietf.org/doc/draft-kazuho-h2-cache-digest/>
75 * that describes how to use golomb filters.
76 */
77
79
81
84 int NMax; /* Maximum for N, should size change be necessary */
85 int N; /* Current maximum number of entries, power of 2 */
86 apr_uint64_t mask; /* mask for relevant bits */
87 unsigned int mask_bits; /* number of relevant bits */
88 const char *authority;
91};
92
102#if AP_HAS_RESPONSE_BUCKETS
104 const struct h2_request *req,
105 apr_uint32_t push_policy,
106 const ap_bucket_response *res);
107#else
109 const struct h2_request *req,
110 apr_uint32_t push_policy,
111 const struct h2_headers *res);
112#endif
113
122
128
133#if AP_HAS_RESPONSE_BUCKETS
135 const struct h2_request *req,
136 const ap_bucket_response *res);
137#else
139 const struct h2_request *req,
140 const struct h2_headers *res);
141#endif
142
155 int maxP, const char *authority,
156 const char **pdata, apr_size_t *plen);
157
158#endif /* defined(__mod_h2__h2_push__) */
apr_pool_t apr_dbd_t apr_dbd_results_t ** res
Definition apr_dbd.h:287
apr_size_t size
int apr_status_t
Definition apr_errno.h:44
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)
Definition h2_push.c:441
apr_array_header_t * h2_push_collect_update(struct h2_stream *stream, const struct h2_request *req, const struct h2_headers *res)
Definition h2_push.c:692
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)
Definition h2_push.c:806
h2_push_digest_type
Definition h2_push.h:35
@ H2_PUSH_DIGEST_SHA256
Definition h2_push.h:37
@ H2_PUSH_DIGEST_APR_HASH
Definition h2_push.h:36
apr_array_header_t * h2_push_diary_update(struct h2_session *session, apr_array_header_t *pushes)
Definition h2_push.c:651
h2_push_diary * h2_push_diary_create(apr_pool_t *p, int N)
Definition h2_push.c:585
void h2_push_digest_calc(h2_push_diary *diary, apr_uint64_t *phash, h2_push *push)
Definition h2_push.h:80
HTTP protocol handling.
apr_pool_t * p
Definition md_event.c:32
h2_push_digest_type dtype
Definition h2_push.h:89
unsigned int mask_bits
Definition h2_push.h:87
apr_uint64_t mask
Definition h2_push.h:86
h2_push_digest_calc * dcalc
Definition h2_push.h:90
apr_array_header_t * entries
Definition h2_push.h:83
const char * authority
Definition h2_push.h:88
const struct h2_request * req
Definition h2_push.h:31
h2_priority * priority
Definition h2_push.h:32