summaryrefslogtreecommitdiffstats
path: root/web/server/h2o/streaming.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-03-09 13:19:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-03-09 13:20:02 +0000
commit58daab21cd043e1dc37024a7f99b396788372918 (patch)
tree96771e43bb69f7c1c2b0b4f7374cb74d7866d0cb /web/server/h2o/streaming.h
parentReleasing debian version 1.43.2-1. (diff)
downloadnetdata-58daab21cd043e1dc37024a7f99b396788372918.tar.xz
netdata-58daab21cd043e1dc37024a7f99b396788372918.zip
Merging upstream version 1.44.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/server/h2o/streaming.h')
-rw-r--r--web/server/h2o/streaming.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/web/server/h2o/streaming.h b/web/server/h2o/streaming.h
new file mode 100644
index 000000000..ae6447257
--- /dev/null
+++ b/web/server/h2o/streaming.h
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#ifndef HTTPD_STREAMING_H
+#define HTTPD_STREAMING_H
+
+#include "daemon/common.h"
+#include "mqtt_websockets/c-rbuf/include/ringbuffer.h"
+#include "h2o.h"
+
+typedef enum {
+ STREAM_X_HTTP_1_1 = 0,
+ STREAM_X_HTTP_1_1_DONE,
+ STREAM_ACTIVE,
+ STREAM_CLOSE
+} h2o_stream_state_t;
+
+typedef enum {
+ HTTP_STREAM = 0,
+ HTTP_URL,
+ HTTP_PROTO,
+ HTTP_USER_AGENT_KEY,
+ HTTP_USER_AGENT_VALUE,
+ HTTP_HDR,
+ HTTP_DONE
+} http_stream_parse_state_t;
+
+typedef struct {
+ h2o_socket_t *sock;
+ h2o_stream_state_t state;
+
+ rbuf_t rx;
+ pthread_cond_t rx_buf_cond;
+ pthread_mutex_t rx_buf_lock;
+
+ rbuf_t tx;
+ h2o_iovec_t tx_buf;
+ pthread_mutex_t tx_buf_lock;
+
+ http_stream_parse_state_t parse_state;
+ char *url;
+ char *user_agent;
+
+ int shutdown;
+} h2o_stream_conn_t;
+
+// h2o_stream_conn_t related functions
+void h2o_stream_conn_t_init(h2o_stream_conn_t *conn);
+void h2o_stream_conn_t_destroy(h2o_stream_conn_t *conn);
+
+// streaming upgrade related functions
+int is_streaming_handshake(h2o_req_t *req);
+void stream_on_complete(void *user_data, h2o_socket_t *sock, size_t reqsize);
+
+// read and write functions to be used by streaming parser
+int h2o_stream_write(void *ctx, const char *data, size_t data_len);
+size_t h2o_stream_read(void *ctx, char *buf, size_t read_bytes);
+
+// call this periodically to check if there are any pending write requests
+void h2o_stream_check_pending_write_reqs(void);
+
+#endif /* HTTPD_STREAMING_H */