1 /* Copyright 2015 greenbytes GmbH (https://www.greenbytes.de)
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #ifndef __mod_h2__h2_ctx__
17 #define __mod_h2__h2_ctx__
24 * The h2 module context associated with a connection.
26 * It keeps track of the different types of connections:
27 * - those from clients that use HTTP/2 protocol
28 * - those from clients that do not use HTTP/2
29 * - those created by ourself to perform work on HTTP/2 streams
31 typedef struct h2_ctx {
32 const char *protocol; /* the protocol negotiated */
33 struct h2_session *session; /* the session established */
34 struct h2_task *task; /* the h2_task executing or NULL */
35 const char *hostname; /* hostname negotiated via SNI, optional */
36 server_rec *server; /* httpd server config selected. */
37 const struct h2_config *config; /* effective config in this context */
41 * Get (or create) a h2 context record for this connection.
42 * @param c the connection to look at
43 * @param create != 0 iff missing context shall be created
44 * @return h2 context of this connection
46 h2_ctx *h2_ctx_get(const conn_rec *c, int create);
47 void h2_ctx_clear(const conn_rec *c);
49 h2_ctx *h2_ctx_rget(const request_rec *r);
50 h2_ctx *h2_ctx_create_for(const conn_rec *c, struct h2_task *task);
53 /* Set the h2 protocol established on this connection context or
54 * NULL when other protocols are in place.
56 h2_ctx *h2_ctx_protocol_set(h2_ctx *ctx, const char *proto);
58 /* Set the server_rec relevant for this context.
60 h2_ctx *h2_ctx_server_set(h2_ctx *ctx, server_rec *s);
61 server_rec *h2_ctx_server_get(h2_ctx *ctx);
63 struct h2_session *h2_ctx_session_get(h2_ctx *ctx);
64 void h2_ctx_session_set(h2_ctx *ctx, struct h2_session *session);
67 * Get the h2 protocol negotiated for this connection, or NULL.
69 const char *h2_ctx_protocol_get(const conn_rec *c);
71 int h2_ctx_is_task(h2_ctx *ctx);
73 struct h2_task *h2_ctx_get_task(h2_ctx *ctx);
74 struct h2_task *h2_ctx_cget_task(conn_rec *c);
75 struct h2_task *h2_ctx_rget_task(request_rec *r);
77 #endif /* defined(__mod_h2__h2_ctx__) */