]> arthur.barton.de Git - netdata.git/blob - src/web_client.h
splitted netdata to multiple source files
[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
8 #include "web_buffer.h"
9
10 #ifndef NETDATA_WEB_CLIENT_H
11 #define NETDATA_WEB_CLIENT_H 1
12
13 #define WEB_CLIENT_MODE_NORMAL          0
14 #define WEB_CLIENT_MODE_FILECOPY        1
15
16 #define URL_MAX 8192
17 #define ZLIB_CHUNK      16384
18 #define MAX_HTTP_HEADER_SIZE 16384
19
20 struct web_client {
21         unsigned long long id;
22         char client_ip[101];
23         char last_url[URL_MAX+1];
24
25         struct timeval tv_in, tv_ready;
26
27         int mode;
28         int keepalive;
29
30         struct sockaddr_in clientaddr;
31
32         pthread_t thread;                               // the thread servicing this client
33         int obsolete;                                   // if set to 1, the listener will remove this client
34
35         int ifd;
36         int ofd;
37
38         struct web_buffer *data;
39
40         int zoutput;                                    // if set to 1, web_client_send() will send compressed data
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
45         int zinitialized;
46
47         int wait_receive;
48         int wait_send;
49
50         char response_header[MAX_HTTP_HEADER_SIZE+1];
51
52         struct web_client *prev;
53         struct web_client *next;
54 };
55
56 extern struct web_client *web_clients;
57
58 extern struct web_client *web_client_create(int listener);
59 extern struct web_client *web_client_free(struct web_client *w);
60
61 #endif