From ff0b64dce2abb1f4e77cffaeb4a954fd5f985326 Mon Sep 17 00:00:00 2001 From: Costa Tsaousis Date: Mon, 26 Jun 2023 11:37:47 +0300 Subject: URL rewrite at the agent web server to support multiple dashboard versions (#15247) * new routing for web requests * renamed and better error control * add missing return statements * do not serve files when no file extension is given * restore the api of the functions; use internal web_client flags to keep state; support redirects to fix directories * add window.location.hash to url redirect * do not redirect when sending to specific dashboard version and there are data after the version * uniform function to append slash to URL * remove obsolete proxy https flag --- libnetdata/buffer/buffer.h | 17 +++++++---------- libnetdata/http/http_defs.h | 1 + 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'libnetdata') diff --git a/libnetdata/buffer/buffer.h b/libnetdata/buffer/buffer.h index 0021c38ff6..5aaa26a079 100644 --- a/libnetdata/buffer/buffer.h +++ b/libnetdata/buffer/buffer.h @@ -242,19 +242,16 @@ static inline void buffer_strncat(BUFFER *wb, const char *txt, size_t len) { if(unlikely(!txt || !*txt)) return; const char *t = txt; - while(*t) { - buffer_need_bytes(wb, len); - char *s = &wb->buffer[wb->len]; - char *d = s; - const char *e = &wb->buffer[wb->len + len]; + buffer_need_bytes(wb, len + 1); + char *s = &wb->buffer[wb->len]; + char *d = s; + const char *e = &wb->buffer[wb->len + len]; - while(*t && d < e) - *d++ = *t++; + while(*t && d < e) + *d++ = *t++; - wb->len += d - s; - } + wb->len += d - s; - buffer_need_bytes(wb, 1); wb->buffer[wb->len] = '\0'; buffer_overflow_check(wb); diff --git a/libnetdata/http/http_defs.h b/libnetdata/http/http_defs.h index 774ea0b71d..906e3bdfb2 100644 --- a/libnetdata/http/http_defs.h +++ b/libnetdata/http/http_defs.h @@ -10,6 +10,7 @@ #define HTTP_RESP_MOVED_PERM 301 #define HTTP_RESP_REDIR_TEMP 307 #define HTTP_RESP_REDIR_PERM 308 +#define HTTP_RESP_HTTPS_UPGRADE 399 // HTTP_CODES 4XX Client Errors #define HTTP_RESP_BAD_REQUEST 400 -- cgit v1.2.3