2 #ifdef NETDATA_WITH_ZLIB
8 #include <sys/socket.h>
9 #include <netinet/in.h>
10 #include <arpa/inet.h>
13 #include "web_buffer.h"
14 #include "dictionary.h"
16 #define DEFAULT_DISCONNECT_IDLE_WEB_CLIENTS_AFTER_SECONDS 60
17 extern int web_client_timeout;
18 extern int web_enable_gzip;
20 #ifndef NETDATA_WEB_CLIENT_H
21 #define NETDATA_WEB_CLIENT_H 1
23 #define WEB_CLIENT_MODE_NORMAL 0
24 #define WEB_CLIENT_MODE_FILECOPY 1
25 #define WEB_CLIENT_MODE_OPTIONS 2
28 #define ZLIB_CHUNK 16384
29 #define HTTP_RESPONSE_HEADER_SIZE 4096
30 #define COOKIE_MAX 1024
31 #define ORIGIN_MAX 1024
34 BUFFER *header; // our response header
35 BUFFER *header_output; // internal use
36 BUFFER *data; // our response data buffer
38 int code; // the HTTP response code
40 size_t rlen; // if non-zero, the excepted size of ifd (input)
41 size_t sent; // current data length sent to output
43 int zoutput; // if set to 1, web_client_send() will send compressed data
44 #ifdef NETDATA_WITH_ZLIB
45 z_stream zstream; // zlib stream for sending compressed output to client
46 Bytef zbuffer[ZLIB_CHUNK]; // temporary buffer for storing compressed output
47 long zsent; // the compressed bytes we have sent to the client
48 long zhave; // the compressed bytes that we have to send
55 unsigned long long id;
57 char client_ip[NI_MAXHOST+1];
58 char client_port[NI_MAXSERV+1];
60 char last_url[URL_MAX+1];
62 struct timeval tv_in, tv_ready;
64 char cookie[COOKIE_MAX+1];
65 char origin[ORIGIN_MAX+1];
72 struct sockaddr_storage clientaddr;
74 pthread_t thread; // the thread servicing this client
75 int obsolete; // if set to 1, the listener will remove this client
80 struct response response;
85 struct web_client *prev;
86 struct web_client *next;
89 extern struct web_client *web_clients;
91 extern uid_t web_files_uid(void);
92 extern uid_t web_files_gid(void);
94 extern struct web_client *web_client_create(int listener);
95 extern struct web_client *web_client_free(struct web_client *w);
97 extern void *web_client_main(void *ptr);