summaryrefslogtreecommitdiffstats
path: root/libnetdata
diff options
context:
space:
mode:
authorTimotej S <6674623+underhood@users.noreply.github.com>2023-05-10 13:37:44 +0200
committerGitHub <noreply@github.com>2023-05-10 13:37:44 +0200
commit66c47355b4c0a33f7cef0615fe7331bbce463361 (patch)
tree728e4ac73f09d893d32d6c851c9bd316f158430e /libnetdata
parent836a56a956f252935dd2ed4908aab57e1a95ccaf (diff)
initial minimal h2o webserver integration (#14585)
Introduces h2o based web server as an alternative
Diffstat (limited to 'libnetdata')
-rw-r--r--libnetdata/buffer/buffer.c8
-rw-r--r--libnetdata/buffer/buffer.h8
-rw-r--r--libnetdata/http/http_defs.h30
-rw-r--r--libnetdata/libnetdata.h1
4 files changed, 47 insertions, 0 deletions
diff --git a/libnetdata/buffer/buffer.c b/libnetdata/buffer/buffer.c
index 142fbca143..91bc4dd602 100644
--- a/libnetdata/buffer/buffer.c
+++ b/libnetdata/buffer/buffer.c
@@ -503,3 +503,11 @@ int buffer_unittest(void) {
return errors;
}
+#ifdef ENABLE_HTTPD
+h2o_iovec_t buffer_to_h2o_iovec(BUFFER *wb) {
+ h2o_iovec_t ret;
+ ret.base = wb->buffer;
+ ret.len = wb->len;
+ return ret;
+}
+#endif
diff --git a/libnetdata/buffer/buffer.h b/libnetdata/buffer/buffer.h
index f5f83bc2ae..22686a5a16 100644
--- a/libnetdata/buffer/buffer.h
+++ b/libnetdata/buffer/buffer.h
@@ -6,6 +6,10 @@
#include "../string/utf8.h"
#include "../libnetdata.h"
+#ifdef ENABLE_HTTPD
+#include "h2o/memory.h"
+#endif
+
#define WEB_DATA_LENGTH_INCREASE_STEP 1024
#define BUFFER_JSON_MAX_DEPTH 32 // max is 255
@@ -129,6 +133,10 @@ void buffer_char_replace(BUFFER *wb, char from, char to);
void buffer_print_sn_flags(BUFFER *wb, SN_FLAGS flags, bool send_anomaly_bit);
+#ifdef ENABLE_HTTPD
+h2o_iovec_t buffer_to_h2o_iovec(BUFFER *wb);
+#endif
+
static inline void buffer_need_bytes(BUFFER *buffer, size_t needed_free_size) {
if(unlikely(buffer->len + needed_free_size >= buffer->size))
buffer_increase(buffer, needed_free_size + 1);
diff --git a/libnetdata/http/http_defs.h b/libnetdata/http/http_defs.h
new file mode 100644
index 0000000000..774ea0b71d
--- /dev/null
+++ b/libnetdata/http/http_defs.h
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#ifndef NETDATA_HTTP_DEFS_H
+#define NETDATA_HTTP_DEFS_H
+
+// HTTP_CODES 2XX Success
+#define HTTP_RESP_OK 200
+
+// HTTP_CODES 3XX Redirections
+#define HTTP_RESP_MOVED_PERM 301
+#define HTTP_RESP_REDIR_TEMP 307
+#define HTTP_RESP_REDIR_PERM 308
+
+// HTTP_CODES 4XX Client Errors
+#define HTTP_RESP_BAD_REQUEST 400
+#define HTTP_RESP_UNAUTHORIZED 401
+#define HTTP_RESP_FORBIDDEN 403
+#define HTTP_RESP_NOT_FOUND 404
+#define HTTP_RESP_CONFLICT 409
+#define HTTP_RESP_PRECOND_FAIL 412
+#define HTTP_RESP_CONTENT_TOO_LONG 413
+
+// HTTP_CODES 5XX Server Errors
+#define HTTP_RESP_INTERNAL_SERVER_ERROR 500
+#define HTTP_RESP_BACKEND_FETCH_FAILED 503 // 503 is right
+#define HTTP_RESP_SERVICE_UNAVAILABLE 503 // 503 is right
+#define HTTP_RESP_GATEWAY_TIMEOUT 504
+#define HTTP_RESP_BACKEND_RESPONSE_INVALID 591
+
+#endif /* NETDATA_HTTP_DEFS_H */
diff --git a/libnetdata/libnetdata.h b/libnetdata/libnetdata.h
index c244949308..db61fe3647 100644
--- a/libnetdata/libnetdata.h
+++ b/libnetdata/libnetdata.h
@@ -667,6 +667,7 @@ extern char *netdata_configured_host_prefix;
#include "worker_utilization/worker_utilization.h"
#include "parser/parser.h"
#include "yaml.h"
+#include "http/http_defs.h"
// BEWARE: this exists in alarm-notify.sh
#define DEFAULT_CLOUD_BASE_URL "https://app.netdata.cloud"