summaryrefslogtreecommitdiffstats
path: root/web/server/web_client.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-02-07 11:45:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-02-07 11:45:55 +0000
commita8220ab2d293bb7f4b014b79d16b2fb05090fa93 (patch)
tree77f0a30f016c0925cf7ee9292e644bba183c2774 /web/server/web_client.h
parentAdding upstream version 1.19.0. (diff)
downloadnetdata-a8220ab2d293bb7f4b014b79d16b2fb05090fa93.tar.xz
netdata-a8220ab2d293bb7f4b014b79d16b2fb05090fa93.zip
Adding upstream version 1.29.0.upstream/1.29.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/server/web_client.h')
-rw-r--r--web/server/web_client.h115
1 files changed, 58 insertions, 57 deletions
diff --git a/web/server/web_client.h b/web/server/web_client.h
index c785a7fda..48bf1ac86 100644
--- a/web/server/web_client.h
+++ b/web/server/web_client.h
@@ -6,24 +6,22 @@
#include "libnetdata/libnetdata.h"
#ifdef NETDATA_WITH_ZLIB
-extern int web_enable_gzip,
- web_gzip_level,
- web_gzip_strategy;
+extern int web_enable_gzip, web_gzip_level, web_gzip_strategy;
#endif /* NETDATA_WITH_ZLIB */
// HTTP_CODES 2XX Success
-#define HTTP_RESP_OK 200
+#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
+#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_FORBIDDEN 403
-#define HTTP_RESP_NOT_FOUND 404
-#define HTTP_RESP_PRECOND_FAIL 412
+#define HTTP_RESP_BAD_REQUEST 400
+#define HTTP_RESP_FORBIDDEN 403
+#define HTTP_RESP_NOT_FOUND 404
+#define HTTP_RESP_PRECOND_FAIL 412
// HTTP_CODES 5XX Server Errors
#define HTTP_RESP_INTERNAL_SERVER_ERROR 500
@@ -33,10 +31,10 @@ extern int respect_web_browser_do_not_track_policy;
extern char *web_x_frame_options;
typedef enum web_client_mode {
- WEB_CLIENT_MODE_NORMAL = 0,
- WEB_CLIENT_MODE_FILECOPY = 1,
- WEB_CLIENT_MODE_OPTIONS = 2,
- WEB_CLIENT_MODE_STREAM = 3
+ WEB_CLIENT_MODE_NORMAL = 0,
+ WEB_CLIENT_MODE_FILECOPY = 1,
+ WEB_CLIENT_MODE_OPTIONS = 2,
+ WEB_CLIENT_MODE_STREAM = 3
} WEB_CLIENT_MODE;
typedef enum {
@@ -52,20 +50,22 @@ typedef enum {
} HTTP_VALIDATION;
typedef enum web_client_flags {
- WEB_CLIENT_FLAG_DEAD = 1 << 1, // if set, this client is dead
+ WEB_CLIENT_FLAG_DEAD = 1 << 1, // if set, this client is dead
- WEB_CLIENT_FLAG_KEEPALIVE = 1 << 2, // if set, the web client will be re-used
+ WEB_CLIENT_FLAG_KEEPALIVE = 1 << 2, // if set, the web client will be re-used
- WEB_CLIENT_FLAG_WAIT_RECEIVE = 1 << 3, // if set, we are waiting more input data
- WEB_CLIENT_FLAG_WAIT_SEND = 1 << 4, // if set, we have data to send to the client
+ WEB_CLIENT_FLAG_WAIT_RECEIVE = 1 << 3, // if set, we are waiting more input data
+ WEB_CLIENT_FLAG_WAIT_SEND = 1 << 4, // if set, we have data to send to the client
- WEB_CLIENT_FLAG_DO_NOT_TRACK = 1 << 5, // if set, we should not set cookies on this client
+ WEB_CLIENT_FLAG_DO_NOT_TRACK = 1 << 5, // if set, we should not set cookies on this client
WEB_CLIENT_FLAG_TRACKING_REQUIRED = 1 << 6, // if set, we need to send cookies
- WEB_CLIENT_FLAG_TCP_CLIENT = 1 << 7, // if set, the client is using a TCP socket
- WEB_CLIENT_FLAG_UNIX_CLIENT = 1 << 8, // if set, the client is using a UNIX socket
+ WEB_CLIENT_FLAG_TCP_CLIENT = 1 << 7, // if set, the client is using a TCP socket
+ WEB_CLIENT_FLAG_UNIX_CLIENT = 1 << 8, // if set, the client is using a UNIX socket
- WEB_CLIENT_FLAG_DONT_CLOSE_SOCKET = 1 << 9, // don't close the socket when cleaning up (static-threaded web server)
+ WEB_CLIENT_FLAG_DONT_CLOSE_SOCKET = 1 << 9, // don't close the socket when cleaning up (static-threaded web server)
+
+ WEB_CLIENT_CHUNKED_TRANSFER = 1 << 10, // chunked transfer (used with zlib compression)
} WEB_CLIENT_FLAGS;
//#ifdef HAVE_C___ATOMIC
@@ -74,7 +74,7 @@ typedef enum web_client_flags {
//#define web_client_flag_clear(w, flag) __atomic_and_fetch(&((w)->flags), ~flag, __ATOMIC_SEQ_CST)
//#else
#define web_client_flag_check(w, flag) ((w)->flags & (flag))
-#define web_client_flag_set(w, flag) (w)->flags |= flag
+#define web_client_flag_set(w, flag) (w)->flags |= flag
#define web_client_flag_clear(w, flag) (w)->flags &= ~flag
//#endif
@@ -118,59 +118,59 @@ typedef enum web_client_flags {
#define NETDATA_WEB_REQUEST_MAX_SIZE 16384
struct response {
- BUFFER *header; // our response header
- BUFFER *header_output; // internal use
- BUFFER *data; // our response data buffer
+ BUFFER *header; // our response header
+ BUFFER *header_output; // internal use
+ BUFFER *data; // our response data buffer
- int code; // the HTTP response code
+ int code; // the HTTP response code
- size_t rlen; // if non-zero, the excepted size of ifd (input of firecopy)
- size_t sent; // current data length sent to output
+ size_t rlen; // if non-zero, the excepted size of ifd (input of firecopy)
+ size_t sent; // current data length sent to output
- int zoutput; // if set to 1, web_client_send() will send compressed data
+ int zoutput; // if set to 1, web_client_send() will send compressed data
#ifdef NETDATA_WITH_ZLIB
- z_stream zstream; // zlib stream for sending compressed output to client
+ z_stream zstream; // zlib stream for sending compressed output to client
Bytef zbuffer[NETDATA_WEB_RESPONSE_ZLIB_CHUNK_SIZE]; // temporary buffer for storing compressed output
- size_t zsent; // the compressed bytes we have sent to the client
- size_t zhave; // the compressed bytes that we have received from zlib
- unsigned int zinitialized:1;
+ size_t zsent; // the compressed bytes we have sent to the client
+ size_t zhave; // the compressed bytes that we have received from zlib
+ unsigned int zinitialized : 1;
#endif /* NETDATA_WITH_ZLIB */
-
};
struct web_client {
unsigned long long id;
- WEB_CLIENT_FLAGS flags; // status flags for the client
- WEB_CLIENT_MODE mode; // the operational mode of the client
- WEB_CLIENT_ACL acl; // the access list of the client
- int port_acl; // the operations permitted on the port the client connected to
- char *auth_bearer_token; // the Bearer auth token (if sent)
+ WEB_CLIENT_FLAGS flags; // status flags for the client
+ WEB_CLIENT_MODE mode; // the operational mode of the client
+ WEB_CLIENT_ACL acl; // the access list of the client
+ int port_acl; // the operations permitted on the port the client connected to
+ char *auth_bearer_token; // the Bearer auth token (if sent)
size_t header_parse_tries;
size_t header_parse_last_size;
- int tcp_cork; // 1 = we have a cork on the socket
+ int tcp_cork; // 1 = we have a cork on the socket
int ifd;
int ofd;
- char client_ip[INET6_ADDRSTRLEN]; // Defined buffer sizes include null-terminators
+ char client_ip[INET6_ADDRSTRLEN]; // Defined buffer sizes include null-terminators
char client_port[NI_MAXSERV];
char server_host[NI_MAXHOST];
char client_host[NI_MAXHOST];
+ char forwarded_host[NI_MAXHOST]; //Used with proxy
- char decoded_url[NETDATA_WEB_REQUEST_URL_SIZE + 1]; // we decode the URL in this buffer
- char decoded_query_string[NETDATA_WEB_REQUEST_URL_SIZE + 1]; // we decode the Query String in this buffer
- char last_url[NETDATA_WEB_REQUEST_URL_SIZE+1]; // we keep a copy of the decoded URL here
+ char decoded_url[NETDATA_WEB_REQUEST_URL_SIZE + 1]; // we decode the URL in this buffer
+ char decoded_query_string[NETDATA_WEB_REQUEST_URL_SIZE + 1]; // we decode the Query String in this buffer
+ char last_url[NETDATA_WEB_REQUEST_URL_SIZE + 1]; // we keep a copy of the decoded URL here
size_t url_path_length;
- char separator; // This value can be either '?' or 'f'
+ char separator; // This value can be either '?' or 'f'
char *url_search_path; //A pointer to the search path sent by the client
struct timeval tv_in, tv_ready;
- char cookie1[NETDATA_WEB_REQUEST_COOKIE_SIZE+1];
- char cookie2[NETDATA_WEB_REQUEST_COOKIE_SIZE+1];
- char origin[NETDATA_WEB_REQUEST_ORIGIN_HEADER_SIZE+1];
+ char cookie1[NETDATA_WEB_REQUEST_COOKIE_SIZE + 1];
+ char cookie2[NETDATA_WEB_REQUEST_COOKIE_SIZE + 1];
+ char origin[NETDATA_WEB_REQUEST_ORIGIN_HEADER_SIZE + 1];
char *user_agent;
struct response response;
@@ -179,22 +179,21 @@ struct web_client {
size_t stats_sent_bytes;
// cache of web_client allocations
- struct web_client *prev; // maintain a linked list of web clients
- struct web_client *next; // for the web servers that need it
+ struct web_client *prev; // maintain a linked list of web clients
+ struct web_client *next; // for the web servers that need it
// MULTI-THREADED WEB SERVER MEMBERS
- netdata_thread_t thread; // the thread servicing this client
- volatile int running; // 1 when the thread runs, 0 otherwise
+ netdata_thread_t thread; // the thread servicing this client
+ volatile int running; // 1 when the thread runs, 0 otherwise
// STATIC-THREADED WEB SERVER MEMBERS
- size_t pollinfo_slot; // POLLINFO slot of the web client
- size_t pollinfo_filecopy_slot; // POLLINFO slot of the file read
+ size_t pollinfo_slot; // POLLINFO slot of the web client
+ size_t pollinfo_filecopy_slot; // POLLINFO slot of the file read
#ifdef ENABLE_HTTPS
struct netdata_ssl ssl;
#endif
};
-
extern uid_t web_files_uid(void);
extern uid_t web_files_gid(void);
@@ -211,6 +210,8 @@ extern void buffer_data_options2string(BUFFER *wb, uint32_t options);
extern int mysendfile(struct web_client *w, char *filename);
+extern void web_client_build_http_header(struct web_client *w);
+
#include "daemon/common.h"
#endif