#ifndef __mod_h2__h2_conn_io__
#define __mod_h2__h2_conn_io__
+struct h2_config;
+struct h2_session;
+
/* h2_io is the basic handler of a httpd connection. It keeps two brigades,
* one for input, one for output and works with the installed connection
* filters.
* directly without copying.
*/
typedef struct {
- conn_rec *connection;
- apr_bucket_brigade *input;
+ conn_rec *c;
apr_bucket_brigade *output;
- int buffer_output;
- int write_size;
+
+ int is_tls;
+ apr_time_t cooldown_usecs;
+ apr_int64_t warmup_size;
+
+ apr_size_t write_size;
apr_time_t last_write;
- apr_size_t bytes_written;
+ apr_int64_t bytes_read;
+ apr_int64_t bytes_written;
- char *buffer;
- apr_size_t buflen;
- apr_size_t bufsize;
- int unflushed;
+ int buffer_output;
+ int needs_flush;
+ apr_size_t pass_threshold;
+ float flush_factor;
+ float speed_factor;
+
+ char *scratch;
+ apr_size_t ssize;
+ apr_size_t slen;
} h2_conn_io;
-apr_status_t h2_conn_io_init(h2_conn_io *io, conn_rec *c);
-void h2_conn_io_destroy(h2_conn_io *io);
-
-typedef apr_status_t (*h2_conn_io_on_read_cb)(const char *data, apr_size_t len,
- apr_size_t *readlen, int *done,
- void *puser);
-
-apr_status_t h2_conn_io_read(h2_conn_io *io,
- apr_read_type_e block,
- h2_conn_io_on_read_cb on_read_cb,
- void *puser);
+apr_status_t h2_conn_io_init(h2_conn_io *io, conn_rec *c,
+ const struct h2_config *cfg);
+/**
+ * Append data to the buffered output.
+ * @param buf the data to append
+ * @param length the length of the data to append
+ */
apr_status_t h2_conn_io_write(h2_conn_io *io,
const char *buf,
size_t length);
+apr_status_t h2_conn_io_pass(h2_conn_io *io, apr_bucket_brigade *bb);
+
+/**
+ * Append an End-Of-Connection bucket to the output that, once destroyed,
+ * will tear down the complete http2 session.
+ */
+apr_status_t h2_conn_io_write_eoc(h2_conn_io *io, struct h2_session *session);
+
+/**
+ * Pass any buffered data on to the connection output filters.
+ * @param io the connection io
+ * @param flush if a flush bucket should be appended to any output
+ */
apr_status_t h2_conn_io_flush(h2_conn_io *io);
+int h2_conn_io_needs_flush(h2_conn_io *io);
+
#endif /* defined(__mod_h2__h2_conn_io__) */