]> arthur.barton.de Git - netdata.git/blob - src/web_client.h
added config file option to disable web gzip compression
[netdata.git] / src / web_client.h
1 #include <zlib.h>
2 #include <sys/time.h>
3 #include <string.h>
4 #include <sys/socket.h>
5 #include <netinet/in.h>
6 #include <arpa/inet.h>
7 #include <netdb.h>
8
9 #include "web_buffer.h"
10
11 #define DEFAULT_DISCONNECT_IDLE_WEB_CLIENTS_AFTER_SECONDS 60
12 extern int web_client_timeout;
13 extern int web_enable_gzip;
14
15 #ifndef NETDATA_WEB_CLIENT_H
16 #define NETDATA_WEB_CLIENT_H 1
17
18 #define WEB_CLIENT_MODE_NORMAL          0
19 #define WEB_CLIENT_MODE_FILECOPY        1
20
21 #define URL_MAX 8192
22 #define ZLIB_CHUNK      16384
23 #define MAX_HTTP_HEADER_SIZE 16384
24
25 /*
26 struct name_value {
27         char *name;
28         char *value;
29         unsigned long hash;
30         struct name_value *next;
31 };
32
33 struct web_request {
34         char *protocol;
35         char *hostname;
36         char *path;
37         char *query_string;
38
39         struct name_value *headers;
40         struct name_value *query_parameters;
41         struct name_value *post_parameters;
42 };
43 */
44
45 struct web_client {
46         unsigned long long id;
47
48         char client_ip[NI_MAXHOST+1];
49         char client_port[NI_MAXSERV+1];
50
51         char last_url[URL_MAX+1];
52
53         struct web_request *request;
54
55         struct timeval tv_in, tv_ready;
56
57         int mode;
58         int keepalive;
59
60         struct sockaddr_storage clientaddr;
61
62         pthread_t thread;                               // the thread servicing this client
63         int obsolete;                                   // if set to 1, the listener will remove this client
64
65         int ifd;
66         int ofd;
67
68         struct web_buffer *data;
69
70         int zoutput;                                    // if set to 1, web_client_send() will send compressed data
71         z_stream zstream;                               // zlib stream for sending compressed output to client
72         Bytef zbuffer[ZLIB_CHUNK];              // temporary buffer for storing compressed output
73         long zsent;                                     // the compressed bytes we have sent to the client
74         long zhave;                                     // the compressed bytes that we have to send
75         int zinitialized;
76
77         int wait_receive;
78         int wait_send;
79
80         char response_header[MAX_HTTP_HEADER_SIZE+1];
81
82         struct web_client *prev;
83         struct web_client *next;
84 };
85
86 extern struct web_client *web_clients;
87
88 extern struct web_client *web_client_create(int listener);
89 extern struct web_client *web_client_free(struct web_client *w);
90
91 extern void *web_client_main(void *ptr);
92
93 #endif