]> granicus.if.org Git - apache/blob - modules/http2/h2_conn_io.h
2adf13bf7944461db31990a10f41f91282ecf5b2
[apache] / modules / http2 / h2_conn_io.h
1 /* Copyright 2015 greenbytes GmbH (https://www.greenbytes.de)
2  *
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
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  
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.
14  */
15
16 #ifndef __mod_h2__h2_conn_io__
17 #define __mod_h2__h2_conn_io__
18
19 struct h2_config;
20 struct h2_session;
21
22 /* h2_io is the basic handler of a httpd connection. It keeps two brigades,
23  * one for input, one for output and works with the installed connection
24  * filters.
25  * The read is done via a callback function, so that input can be processed
26  * directly without copying.
27  */
28 typedef struct {
29     conn_rec *c;
30     apr_bucket_brigade *output;
31
32     int is_tls;
33     apr_time_t cooldown_usecs;
34     apr_int64_t warmup_size;
35     
36     apr_size_t write_size;
37     apr_time_t last_write;
38     apr_int64_t bytes_read;
39     apr_int64_t bytes_written;
40     
41     int buffer_output;
42     apr_size_t flush_threshold;
43     unsigned int is_flushed : 1;
44     
45     char *scratch;
46     apr_size_t ssize;
47     apr_size_t slen;
48 } h2_conn_io;
49
50 apr_status_t h2_conn_io_init(h2_conn_io *io, conn_rec *c, 
51                              const struct h2_config *cfg);
52
53 /**
54  * Append data to the buffered output.
55  * @param buf the data to append
56  * @param length the length of the data to append
57  */
58 apr_status_t h2_conn_io_write(h2_conn_io *io,
59                          const char *buf,
60                          size_t length);
61
62 apr_status_t h2_conn_io_pass(h2_conn_io *io, apr_bucket_brigade *bb);
63
64 /**
65  * Pass any buffered data on to the connection output filters.
66  * @param io the connection io
67  * @param flush if a flush bucket should be appended to any output
68  */
69 apr_status_t h2_conn_io_flush(h2_conn_io *io);
70
71 /**
72  * Check if the buffered amount of data needs flushing.
73  */
74 int h2_conn_io_needs_flush(h2_conn_io *io);
75
76 #endif /* defined(__mod_h2__h2_conn_io__) */