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