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"
15 #define DEFAULT_DISCONNECT_IDLE_WEB_CLIENTS_AFTER_SECONDS 60
16 extern int web_client_timeout;
17 extern int web_enable_gzip;
19 #ifndef NETDATA_WEB_CLIENT_H
20 #define NETDATA_WEB_CLIENT_H 1
22 #define WEB_CLIENT_MODE_NORMAL 0
23 #define WEB_CLIENT_MODE_FILECOPY 1
26 #define ZLIB_CHUNK 16384
27 #define HTTP_RESPONSE_HEADER_SIZE 4096
30 BUFFER *header; // our response header
31 BUFFER *header_output; // internal use
32 BUFFER *data; // our response data buffer
34 int code; // the HTTP response code
36 size_t rlen; // if non-zero, the excepted size of ifd (input)
37 size_t sent; // current data length sent to output
39 int zoutput; // if set to 1, web_client_send() will send compressed data
40 #ifdef NETDATA_WITH_ZLIB
41 z_stream zstream; // zlib stream for sending compressed output to client
42 Bytef zbuffer[ZLIB_CHUNK]; // temporary buffer for storing compressed output
43 long zsent; // the compressed bytes we have sent to the client
44 long zhave; // the compressed bytes that we have to send
51 unsigned long long id;
53 char client_ip[NI_MAXHOST+1];
54 char client_port[NI_MAXSERV+1];
56 char last_url[URL_MAX+1];
58 struct timeval tv_in, tv_ready;
63 struct sockaddr_storage clientaddr;
65 pthread_t thread; // the thread servicing this client
66 int obsolete; // if set to 1, the listener will remove this client
71 struct response response;
76 struct web_client *prev;
77 struct web_client *next;
80 extern struct web_client *web_clients;
82 extern uid_t web_files_uid(void);
84 extern struct web_client *web_client_create(int listener);
85 extern struct web_client *web_client_free(struct web_client *w);
87 extern void *web_client_main(void *ptr);